Created
August 13, 2013 11:21
-
-
Save jmaicher/6220192 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.app import App | |
from kivy.lang import Builder | |
from kivy.uix.widget import Widget | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.properties import ObjectProperty | |
Builder.load_string(''' | |
<MyContainer>: | |
MyWidget: | |
<MyWidget>: | |
my_button: my_button | |
Button: | |
id: my_button | |
''') | |
class MyContainer(BoxLayout): | |
pass | |
class MyWidget(Widget): | |
my_button = ObjectProperty() | |
def __init__(self, **kwargs): | |
super(MyWidget, self).__init__(**kwargs) | |
print "MyWidget#__init__ has been executed" | |
def on_my_button(self, *args): | |
print "MyWidget#my_button has been set" | |
class MyApp(App): | |
def build(self): | |
# return MyWidget() | |
return MyContainer() | |
MyApp().run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The answer I got in #kivy:
qua-non: kivy tries to delay the building of the gui of the widgets till they are actually needed. So the children inside a widget won't be set untill the next frame after super is called. When manually initializing a widget, properties can be initialised before the call to init/super
=> Yes, the behavior is expected!