You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here are the py and kv codes for a simple app that's aimed at helping me understand referencing objects using kivy properties. My questions are:
Is CustomLayout effectively the root object, since its first button calls for root.move_slider() when pressed?
Can I swap the order of CustomLayout and TestLayout around so that TestLayout becomes the root object because it is on top of the hierarchy and have the app still work the same?
When trying to reference kivy ids within the python file, how do I know when to reference using "self.ids." vs "self.parent.ids."?
I thought root objects aren't enclosed in angle brackets, why is CustomLayout being done so?
py code:
...
class TestLayout(FloatLayout):
pass
class CustomLayout(BoxLayout):
def move_slider(self):
if self.ids._slider.value <= self.ids._slider.max - 5:
self.ids._slider.value += 5
class CustomButton(Button):
def set_text(self):
self.parent.ids._label2.text = 'CHANGED'
class TestApp(App):
def build(self): return TestLayout()
if __name__ == '__main__': TestApp().run()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Here are the py and kv codes for a simple app that's aimed at helping me understand referencing objects using kivy properties. My questions are:
py code:
kv code:
Beta Was this translation helpful? Give feedback.
All reactions