Hi All,
I am running the code fragments in the docs, in particular the last example of:
In the example , a Custom Widget is created, and defined in a '.kv' file (I show it at the bottom of the post,
but its specific content does not seem relevant
fragment of python code:
...........
class Controller(FloatLayout):
'''Create a controller that receives a custom widget from the kv lang file.
Add an action to be called from the kv lang file.
'''
label_wid = ObjectProperty()
info = StringProperty()
def do_action(self):
self.label_wid.text = 'My label after button press'
self.info = 'New info text'
If I run the example, everything is fine, but f I add a method __init__() for the widget as:
def __init__(self, **kwargs):
#basically do nothing
super(FloatLayout, self).__init__(**kwargs)
The window is created, but the button and label are not resized.
What is going on here? What special operations are performed by kivy?
What is the correct way of implementing __init__() for a custom widget?
Kv file:
#:kivy 1.0
<Controller>:
label_wid: my_custom_label
BoxLayout:
orientation: 'vertical'
padding: 20
Button:
text: 'My controller info is: ' + root.info
on_press: root.do_action()
Label:
id: my_custom_label
text: 'My label before button press'