Skip to content

Instantly share code, notes, and snippets.

@MightyThor
Last active December 14, 2015 03:29
Show Gist options
  • Save MightyThor/5021372 to your computer and use it in GitHub Desktop.
Save MightyThor/5021372 to your computer and use it in GitHub Desktop.
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen
# Declare both screen
class MenuScreen(Screen):
def returnstring(self, printstring):
print printstring
pass
class SettingsScreen(Screen):
pass
class ScreenManagerApp(App):
def build(self):
sm = ScreenManager()
sm.add_widget(MenuScreen(name='menu'))
sm.add_widget(SettingsScreen(name='settings'))
return sm
if __name__ == '__main__':
ScreenManagerApp().run()
#:kivy 1.5.1
#:import kivy kivy
<MenuScreen>:
BoxLayout:
Button:
text: 'Goto settings'
on_press: txt_input.focus = False, root.returnstring(txt_input.text)
Button:
text: 'Quit'
TextInput:
id: txt_input
multiline: False
<SettingsScreen>:
BoxLayout:
Button:
text: 'My setting button'
Button:
text: 'Back to menu'
on_press: root.manager.current = 'menu'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment