In this video I’ll show you how to use the Speed Dial Button Menu with KivyMD.
The KivyMD Speed Dial Button, MDFloatingActionButtonSpeedDial, is a little round icon that sits at the bottom of your app. Click on it and it expands with other icons in a sort of menu.
In this video I’ll show you how to make one, and how to write code to function when someone clicks one of the menu icons. We’ll also look at color options.
#kivy #codemy
Python Code: sd.py
GitHub Code: sd.py
from kivy.lang import Builder from kivymd.app import MDApp class MainApp(MDApp): data = { "language-python": "Python", "language-ruby": "Ruby", "language-javascript": "JS" } def callback(self, instance): if instance.icon == 'language-python': lang = "Python" elif instance.icon == 'language-javascript': lang = "JS" elif instance.icon == 'language-ruby': lang = "Ruby" self.root.ids.my_label.text = f'You Pressed {lang}' #Open def open(self): self.root.ids.my_label.text = f'Open!!' # Close def close(self): self.root.ids.my_label.text = f'Close!!!' def build(self): self.theme_cls.theme_style = "Dark" self.theme_cls.primary_palette = "BlueGray" return Builder.load_file('sd.kv') MainApp().run()
Kivy Design Code: sd.kv
GitHub Code: sd.kv
MDBoxLayout: orientation: 'vertical' MDScreen: MDLabel: id: my_label text: "Some Stuff" halign: "center" MDFloatingActionButtonSpeedDial: data: app.data root_button_anim: True #Color stuff #label_text_color: 1,0,0,1 # Text color #bg_color_stack_button: 1,0,0,1 # bg of icon #bg_color_root_button: 1,0,0,1 # speed dial bg #color_icon_root_button: 1,0,0,1 # speed dial text color #color_icon_stack_button: 1,0,0,1 # icond text color #bg_hint_color: 1,0,0,1 icon bgcolor #Pushing the buttons callback: app.callback # Open or Close on_open: app.open() on_close: app.close()
Add comment