Advertisement
here2share

kivy_pro_template.py

Jan 6th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. # kivy_pro_template.py
  4.  
  5. from kivy.config import Config
  6. Config.set('kivy', 'log_level', 'debug')
  7.  
  8. from kivy.app import App
  9. from kivy.lang import Builder
  10. from kivy.factory import Factory
  11. from kivy.uix.boxlayout import BoxLayout
  12.  
  13. kv = """
  14. <NewB@Button>:
  15.    text: 'New button'
  16.  
  17. <Test>:
  18.    orientation: 'vertical'
  19.    Button:
  20.        text: 'Add a new button'
  21.        on_press: root.callback()
  22. """
  23.  
  24. Builder.load_string(kv)
  25.  
  26.  
  27. class Test(BoxLayout):
  28.     def __init__(self, *args, **kwargs):
  29.         super(Test, self).__init__(*args, **kwargs)
  30.         self.callback()
  31.  
  32.     def callback(self):
  33.         self.add_widget(Factory.NewB())
  34.  
  35.  
  36. class TestApp(App):
  37.     def build(self):
  38.         return Test()
  39.  
  40. if __name__ == '__main__':
  41.     TestApp().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement