如何从纯Python的kivymd left_action_items或right_action_items中确定工具栏。
我尝试写:left_action_items:[[''icon.png',lambda x:通过]]
from kivymd.theming import ThemeManager
from kivy.uix.boxlayout import BoxLayout
from kivy.app import App
from kivymd.toolbar import Toolbar
class StartScreen(BoxLayout):
def __init__(self, **args):
super().__init__(**args)
self.orientation = 'vertical'
toolbar = Toolbar(title = 'Welcome', left_action_items = [['red.png', lambda x: print('hello')]])
self.add_widget(toolbar)
class Program(App):
theme_cls = ThemeManager()
title = "Application"
def build(self):
return StartScreen()
Program().run()
写入错误: KeyError ='left_action'
答案 0 :(得分:0)
您可以在实例化left_action_items
小部件之后尝试添加Toolbar
属性。
toolbar = Toolbar(title = "Welcome")
toolbar.left_action_items = [["facebook", lambda x: print('Hello World')]]
您可以在icon_definitions.py的kivymd中找到一些图标。