Public paste
Undefined
By: Guest | Date: Sep 18 2016 03:59 | Format: Python | Expires: never | Size: 1.58 KB | Hits: 315

  1. from kivy.app import App
  2. from kivy.core.window import Window
  3. from kivy.uix.screenmanager import ScreenManager, Screen, WipeTransition
  4. from kivy.properties import ObjectProperty
  5. from kivy.lang import Builder
  6. from kivy.properties import StringProperty
  7. from kivy.modules import inspector
  8. from kivy.uix.popup import Popup
  9. from kivy.uix.button import Button
  10. from kivy.uix.label import Label
  11. from kivy.uix.gridlayout import GridLayout
  12.  
  13.  
  14. class TitleScreen(Screen):
  15.     def on_pre_enter(self):
  16.         self.ids.grid.add_widget(Label(text="I'm a widget"))
  17.  
  18. class Manager(ScreenManager):
  19.     MainMenu_Screen = ObjectProperty(None)
  20.  
  21. class ScreensApp(App):
  22.     def build(self):
  23.         m = Manager(transition=WipeTransition())
  24.         m.current = 'TitleScreen'
  25.         inspector.create_inspector(Window, m)
  26.         return m
  27.    
  28. if __name__ == "__main__":
  29.     app = ScreensApp()
  30.     app.run()
  31.  
  32.  
  33.  
  34.  
  35. ====================================
  36.  
  37.  
  38.  
  39. <TitleScreen>:
  40.     ScrollView:
  41.         GridLayout:
  42.             id: grid
  43.             cols: 1
  44.             padding: 10
  45.             spacing: 10
  46.             size_hint_y:  None
  47.             do_scroll_x: True
  48.             height: self.minimum_height
  49.             Button:
  50.                 text: 'Refresh'
  51.                 size_hint_x: .1
  52.                 size_hint_y: .1
  53.                 on_press: root.manager.current = 'TitleScreen'
  54.                 size_hint_y: None
  55.  
  56.  
  57.  
  58.  
  59. <Manager>:
  60.     id: screen_manager
  61.     title_screen: title_screen
  62.     TitleScreen:
  63.         id: title_screen
  64.         name: 'TitleScreen'
  65.         manager: screen_manager