Skip to content

Instantly share code, notes, and snippets.

@kaustubhgupta
Created August 9, 2020 09:00
Show Gist options
  • Save kaustubhgupta/ba8de099731871fdf51d1ed7be424c84 to your computer and use it in GitHub Desktop.
Save kaustubhgupta/ba8de099731871fdf51d1ed7be424c84 to your computer and use it in GitHub Desktop.
from kivymd.app import MDApp
from kivy.lang import Builder
kv = """
Screen:
MDLabel:
text: ""
id: txt
pos_hint: {'center_x': 0.5, 'center_y': 0.6}
MDRaisedButton:
text: 'Action Button'
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
on_press:
app.action()
MDRoundFlatButton:
text: 'MDRoundFlatButton'
pos_hint: {'center_x': 0.5, 'center_y': 0.4}
MDRectangleFlatButton:
text: 'MDRectangleFlatButton'
pos_hint: {'center_x': 0.5, 'center_y': 0.3}
MDRectangleFlatIconButton:
text: 'MDRectangleFlatIconButton'
pos_hint: {'center_x': 0.5, 'center_y': 0.2}
width: dp(230)
icon: 'google'
MDFillRoundFlatIconButton:
text: 'MDFillRoundFlatIconButton'
pos_hint: {'center_x': 0.5, 'center_y': 0.1}
width: dp(230)
icon: 'google'
MDFloatingActionButtonSpeedDial:
data: app.data
rotation_root_button: True
"""
class Main(MDApp):
data = {
'language-python': 'Python',
'language-php': 'PHP',
'language-cpp': 'C++',
}
def action(self):
label = self.root.ids.txt
label.text = "This text is displayed after pressing button"
def build(self):
return Builder.load_string(kv)
Main().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment