Advertisement
Guest User

Untitled

a guest
Sep 4th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. from kivy.app import App
  2. from kivy.lang import Builder
  3. from kivy.properties import StringProperty
  4.  
  5.  
  6. kv = '''
  7. BoxLayout:
  8. orientation: 'vertical'
  9. BoxLayout:
  10. size_hint_y: None
  11. height: 50
  12. Button:
  13. text: 'previous'
  14. on_press:
  15. manager.current = manager.previous()
  16. Button:
  17. text: 'next'
  18. on_press:
  19. manager.current = manager.next()
  20.  
  21. ScreenManager:
  22. id: manager
  23.  
  24. Screen:
  25. name: '1'
  26. FloatLayout:
  27. Label:
  28. text: 'screen 1'
  29. size_hint: None, None
  30. size: self.texture_size
  31. pos_hint: {'center_x': .5, 'top': .8}
  32.  
  33. Label:
  34. text: 'button in screen 2 is %s' % button.state
  35.  
  36. Screen:
  37. name: '2'
  38. BoxLayout:
  39. Label:
  40. text: 'hey, this is screen 2'
  41. ToggleButton:
  42. id: button
  43. text: 'switch me'
  44.  
  45. Screen:
  46. name: '3'
  47. TextInput:
  48. text: app.data
  49. on_text: app.data = self.text
  50.  
  51. Screen:
  52. name: '4'
  53. Label:
  54. text: app.data
  55. '''
  56.  
  57.  
  58. class MyApp(App):
  59. data = StringProperty('initial text')
  60.  
  61. def build(self):
  62. self.bind(data=self.do_something)
  63. return Builder.load_string(kv)
  64.  
  65. def do_something(self, *args):
  66. print 'do_something got called because text changed'
  67.  
  68.  
  69. MyApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement