[英]How to callback many function in each button in FloatingActionButtonSpeedDial in kivy?
from kivymd.app import MDApp
from kivy.lang import Builder
Screen='''
Screen:
MDFloatingActionButtonSpeedDial:
callback:app.callback
data:app.data
rotation_root_button:True
hint_animation:True
bg_hint_color: app.theme_cls.primary_light
'''
class Wolf(MDApp):
data = {
'help-rhombus': 'Help',
'triangle': 'Setting',
'key': 'Register', } #For running app
def callback(self, instance):
{What to do now,so that it can run different function with different button? }
def build(self):
self.theme_cls.theme_style = 'Dark'
self.theme_cls.primary_palette = 'Green'
screen_r = Builder.load_string(screen)
return screen_r
Wolf().run()
I have created 3 callback function by using 'if' function but it execute simultaneously all the callback.我通过使用'if' function 创建了 3 个回调 function 但它同时执行所有回调。 and if you resolved it by 'if' function show upload it here.
如果你通过'if'解决了它 function show 上传到这里。
from kivy.lang import Builder
from kivymd.app import MDApp
screen = '''
Screen:
MDFloatingActionButtonSpeedDial:
callback:app.callback
data:app.data
rotation_root_button:True
hint_animation:True
bg_hint_color: app.theme_cls.primary_light
'''
class Wolf(MDApp):
data = {
'help-rhombus': 'Help',
'triangle': 'Setting',
'key': 'Register', }
def callback(self, instance):
if instance.icon == 'help-rhombus':
print('Callback self.help-rhombus()')
elif instance.icon == 'key':
print('Callback self.key()')
elif instance.icon == 'triangle':
print('Callback self.triangles()')
def build(self):
self.theme_cls.theme_style = 'Dark'
self.theme_cls.primary_palette = 'Green'
screen_r = Builder.load_string(screen)
return screen_r
Wolf().run()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.