Created
May 29, 2013 15:43
-
-
Save inclement/5671304 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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