I am receiving the following error in my Kivy application but I am not sure why and how to fix it:
File \"main.py\", line 16, in __init__
self.seq_text_box =
You can store seq_text_box as an ObjectProperty of MenuBar and set it in the kv file:
class MenuBar(BoxLayout):
seq_text_box = ObjectProperty()
def go(self):
print(self.seq_text_box.text)
and in the kv file:
<MinuRoot>:
orientation: "vertical"
MenuBar:
seq_text_box: seq_text_box
SequenceTextBox:
id: seq_text_box
The reason you receive the error is because in the constructor the ids haven't been populated from the rules specified in the kv file.
If you do want to use a plain attribute, you can schedule a Clock event:
class MenuBar(BoxLayout):
def __init__(self, **kwargs):
super(MenuBar, self).__init__(**kwargs)
Clock.schedule_once(self.init_seq_text_box, 0)
def init_seq_text_box(self, *args):
self.seq_text_box = self.parent.ids.seq_text_box
This will schedule a call to init_eq_text_box for the next frame, when ids will be populated.