sd.py
from kivy.lang import Builder
from kivymd.app import MDApp
class MainApp(MDApp):
data = {"Python": "language-python",
"Ruby": "language-ruby",
"JS": "language-javascript"
}
def callback(self,instance):
if (instance.icon == "language-python"):
lan = "Python"
if (instance.icon == "language-ruby"):
lan = "Ruby"
if (instance.icon == "language-javascript"):
lan = "JS"
self.root.ids.my_label.text = f'You Pressed {lan}'
def open(self):
self.root.ids.my_label.text = "Open"
def close(self):
self.root.ids.my_label.text = "Close"
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "BlueGray"
return Builder.load_file('sd.kv')
MainApp().run()
sd.kv
BoxLayout:
orientation: 'vertical'
MDScreen:
MDLabel:
id: my_label
text: "Some Stuff"
halign: "center"
MDFloatingActionButtonSpeedDial:
data: app.data
root_button_anim: True
#label_text_color: 0,0,1,1 #text
#bg_color_stack_button: 0,0,1,1 #icon background
#bg_color_root_button: 0,0,1,1 #speed dial background
#color_icon_root_button: 0,0,1,1 #speed dial text
#color_icon_stack_button: 0,0,1,1 #icon color
# Pushing the buttons
callback: app.callback
# Open or close
on_open: app.open()
on_close: app.close()