Skip to content

Instantly share code, notes, and snippets.

@inclement
Created May 29, 2013 15:43
Show Gist options
  • Save inclement/5671304 to your computer and use it in GitHub Desktop.
Save inclement/5671304 to your computer and use it in GitHub Desktop.
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import NumericProperty, ReferenceListProperty, ObjectProperty, ListProperty, AliasProperty, StringProperty, DictProperty, BooleanProperty, StringProperty, OptionProperty
class MyCustomWidget(Widget):
_val1 = NumericProperty(0)
_val2 = NumericProperty(50)
def AddVal1(self):
valToAdd = 26
self._val1 += valToAdd
class AppWidget(BoxLayout):
pass
class TestApp(App):
def build(self):
return AppWidget()
if __name__ == "__main__":
TestApp().run()
<MyCustomWidget>:
pos: 500, 50
size: 150, 150
Label:
text: ("%d/%d" % (root._val1, root._val2))
pos: (root.center_x, root.center_y)
<AppWidget>:
orientation: 'vertical'
MyCustomWidget:
id: cw
Label:
text: str(cw._val1) + ' ' + str(cw._val2)
Button:
text: 'Add to val1'
on_press: cw.AddVal1()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment