Last active
August 29, 2015 14:09
-
-
Save Cheaterman/d62a27e48a0b43db4618 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.config import Config | |
# Set your maxfps like this: | |
Config.set('graphics', 'maxfps', 5) | |
from kivy.app import App | |
from kivy.lang import Builder | |
from kivy.uix.screenmanager import ScreenManager, Screen, NoTransition | |
Builder.load_string(""" | |
<MenuScreen>: | |
BoxLayout: | |
orientation: 'vertical' | |
canvas: | |
Color: | |
rgb: 0, 0, 0 | |
Rectangle: | |
size: self.size | |
Label: | |
text: 'foo' | |
font_size: 120 | |
Button: | |
on_press: root.manager.current = 'settings' | |
text: 'Goto bar' | |
<SettingsScreen>: | |
BoxLayout: | |
orientation: 'vertical' | |
canvas: | |
Color: | |
rgb: 0, 0, 0 | |
Rectangle: | |
size: self.size | |
Label: | |
text: 'bar' | |
font_size: 80 | |
Button: | |
text: 'Back to foo' | |
on_press: root.manager.current = 'menu' | |
""") | |
# Declare both screens | |
class MenuScreen(Screen): | |
pass | |
class SettingsScreen(Screen): | |
pass | |
# Create the screen manager | |
sm = ScreenManager(transition=NoTransition()) | |
sm.add_widget(MenuScreen(name='menu')) | |
sm.add_widget(SettingsScreen(name='settings')) | |
class TestApp(App): | |
def build(self): | |
return sm | |
if __name__ == '__main__': | |
TestApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment