I'm hoping there's a way to do this but not entirely sure. I want a way to update all of my labels after a button press. This is how I'm currently doing it which throws an error but I don't quite understand it.
At the moment I'm trying to add an id to the custom label and then call it but that doesn't work.
Python Code:
from kivy.lang import Builder
from kivymd.app import MDApp
class MainApp(MDApp):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.screen = Builder.load_file("main.kv")
def build(self):
self.theme_cls.theme_style = "Dark"
return self.screen
def button_press(self):
self.root.ids.custom_label.text = "Two"
if __name__ == '__main__':
MainApp().run()
Kivy File:
<MDLabel>
id: custom_label
text: "One"
halign: "center"
BoxLayout:
orientation: "vertical"
MDLabel
MDLabel
MDRoundFlatButton:
text: "Press"
pos_hint: {"center_x": 0.5, "center_y": 0.5}
on_release: app.button_press()