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

  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.     """
  16.    def on_pre_enter(self):
  17.        I need to add widgets to the GridLayout
  18.    """        
  19.     pass
  20.  
  21. class Manager(ScreenManager):
  22.     MainMenu_Screen = ObjectProperty(None)
  23.  
  24. class ScreensApp(App):
  25.     def build(self):
  26.         m = Manager(transition=WipeTransition())
  27.         m.current = 'TitleScreen'
  28.         inspector.create_inspector(Window, m)
  29.         return m
  30.    
  31. if __name__ == "__main__":
  32.     app = ScreensApp()
  33.     app.run()
  34.  
  35.  
  36.  
  37.  
  38. ====================================
  39.  
  40.  
  41.  
  42. <TitleScreen>:
  43.     ScrollView:
  44.         GridLayout:
  45.             cols: 1
  46.             padding: 10
  47.             spacing: 10
  48.             size_hint_y:  None
  49.             do_scroll_x: True
  50.             height: self.minimum_height
  51.             Button:
  52.                 text: 'Refresh'
  53.                 size_hint_x: .1
  54.                 size_hint_y: .1
  55.                 on_press: root.manager.current = 'TitleScreen'
  56.                 size_hint_y: None
  57.  
  58.  
  59.  
  60.  
  61. <Manager>:
  62.     id: screen_manager
  63.     title_screen: title_screen
  64.     TitleScreen:
  65.         id: title_screen
  66.         name: 'TitleScreen'
  67.         manager: screen_manager