Skip to content

Instantly share code, notes, and snippets.

@tshirtman
Created February 20, 2013 22:29
Show Gist options
  • Save tshirtman/5000276 to your computer and use it in GitHub Desktop.
Save tshirtman/5000276 to your computer and use it in GitHub Desktop.
from kivy.app import App
from kivy.lang import Builder
from kivy.properties import StringProperty
kv = '''
BoxLayout:
orientation: 'vertical'
BoxLayout:
size_hint_y: None
height: 50
Button:
text: 'previous'
on_press:
manager.current = manager.previous()
Button:
text: 'next'
on_press:
manager.current = manager.next()
ScreenManager:
id: manager
Screen:
name: '1'
FloatLayout:
Label:
text: 'screen 1'
size_hint: None, None
size: self.texture_size
pos_hint: {'center_x': .5, 'top': .8}
Label:
text: 'button in screen 2 is %s' % button.state
Screen:
name: '2'
BoxLayout:
Label:
text: 'hey, this is screen 2'
ToggleButton:
id: button
text: 'switch me'
Screen:
name: '3'
TextInput:
text: app.data
on_text: app.data = self.text
Screen:
name: '4'
Label:
text: app.data
'''
class MyApp(App):
data = StringProperty('initial text')
def build(self):
self.bind(data=self.do_something)
return Builder.load_string(kv)
def do_something(self, *args):
print 'do_something got called because text changed'
MyApp().run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment