kivy-按下MDFloatingActionButtonSpeedDial后如何添加功能
kivy- how to add function after press MDFloatingActionButtonSpeedDial
我在 kivymd 中使用浮动操作按钮快速拨号。我想在按下单个按钮后添加功能(导航到另一个屏幕)。任何人都可以通过示例告诉我我该怎么做吗?
<HomeScreen>:
name: "home"
MDFloatingActionButtonSpeedDial:
data:
{'home': 'Domov',
'lightning-bolt': 'Ciele',
'notebook': 'Moje testy'}
<TestScreen>:
name: "test"
<GoalsScreen>:
name: "goals"
<HistoryScreen>:
name: "history"
我试过类似普通按钮的东西,但它没有
没用。
on_release:
root.manager.current = "test"
您可以在 MDFloatingActionButtonSpeedDial
中添加一个 callback
:
MDFloatingActionButtonSpeedDial:
callback: app.call
data:
{'home': 'Domov',
'lightning-bolt': 'Ciele',
'notebook': 'Moje testy'}
使用应用程序中定义的 call()
方法:
def call(self, button):
print('called from', button)
然后按下任何按钮都会触发 call()
方法。
我在 kivymd 中使用浮动操作按钮快速拨号。我想在按下单个按钮后添加功能(导航到另一个屏幕)。任何人都可以通过示例告诉我我该怎么做吗?
<HomeScreen>:
name: "home"
MDFloatingActionButtonSpeedDial:
data:
{'home': 'Domov',
'lightning-bolt': 'Ciele',
'notebook': 'Moje testy'}
<TestScreen>:
name: "test"
<GoalsScreen>:
name: "goals"
<HistoryScreen>:
name: "history"
我试过类似普通按钮的东西,但它没有 没用。
on_release:
root.manager.current = "test"
您可以在 MDFloatingActionButtonSpeedDial
中添加一个 callback
:
MDFloatingActionButtonSpeedDial:
callback: app.call
data:
{'home': 'Domov',
'lightning-bolt': 'Ciele',
'notebook': 'Moje testy'}
使用应用程序中定义的 call()
方法:
def call(self, button):
print('called from', button)
然后按下任何按钮都会触发 call()
方法。