I wanted to make a program with an kivy widgets in multiple box Layouts and I wanted to acsess properties of the root widget(level) from the Feld class.
But root.ids.level
did not worked.
Here is my code:
class level(BoxLayout):
kr = StringProperty('kreuz.png')
ks = StringProperty('kreis.png')
class Feld(Widget):
weg = StringProperty('hinterg.png')
def on_touch_down(self, touch):
if self.ids.my_image.collide_point(*touch.pos):
self.weg = root.ids.level.kr
root = Builder.load_string('''
level:
id: level
<level>:
orientation: 'vertical'
BoxLayout:
id: box1
orientation: 'horizontal'
Feld:
pos: 100, 310
id: a1
<Feld>:
Image:
pos: root.pos
id: my_image
source: root.weg
''')
class TTT(App):
def build(self):
return root
if __name__ == "__main__":
TTT().run()