Created
February 17, 2013 20:53
-
-
Save MightyThor/4973396 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#:kivy 1.5.1 | |
#:import kivy kivy | |
<FirstWidget> | |
GridLayout: | |
size: root.size | |
rows: 2 | |
Label: | |
text: 'First Widget' | |
Button: | |
text: 'Go to Second' | |
on_press: app.root.widget_switcher(self.text) | |
<SecondWidget> | |
GridLayout: | |
size: root.size | |
rows: 2 | |
Label: | |
text: 'Second Widget' | |
Button: | |
text: 'Go to First |
This file contains hidden or 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.app import App | |
from kivy.uix.widget import Widget | |
from kivy.uix.floatlayout import FloatLayout | |
class FirstWidget(Widget): | |
def build(self): | |
print "made it to first" | |
class SecondWidget(Widget): | |
def build(self): | |
print "made it to second" | |
class SwitchingWidgets(App): | |
def build(self): | |
parent = FloatLayout() | |
first = FirstWidget() | |
second = SecondWidget() | |
parent.add_widget(first) | |
return parent | |
def widget_switcher(self, string): | |
print string | |
if __name__ == '__main__': | |
SwitchingWidgets().run( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment