from kivy.properties import *
from date time import date
my_int = NumericProperty(42)
my_string = StringProperty('My string')
my_dict = DictProperty({'key': 'value'})
my_obj = ObjectProperty(date())
my_ref = referenceListProperty( my_int, my_string, my_dict, my_obj )
root = MyRootWidget()
box = BoxLayout()
box.add_widget(Button())
box.add_widget(Button())
root.add_widget(box)
MyRootWidget:
BoxLayout:
Button:
Button:
MyWidget:
cols: len(some_data_from_python_file)
on_size: my_callback_method
pos: self.center_x / 2, self.center_y * 2
<MyWidget>:
label_widget: label_widget
Button:
text: 'Add Button'
on_press: root.add_widget(label_widget)
<Marvel>
Label:
id: loki
text: 'Loki: I AM YOUR GOD!'
Button:
id: hulk
text: 'Press to smash Loki'
on_release: root.hulk_smash()
class Marvel(BoxLayout):
def hulk_smash(self):
self.ids.hulk.text = "Hulk: Puny God!"
self.ids.loki.text = "Loki: >_<!!!"