I have three NumericProperteis that i wanna update every second. I tried to use Clock.schedule_interval(), becouse it similar to what i want. How can I update NumericProperteis? Can I use another event that runing in Kivy MainLoop? Or maybe I'm not changing NumericProperty correctly?
from kivy.app import App
from kivy.uix.widget import Widget
from kivy.properties import NumericProperty
from kivy.properties import StringProperty
from kivy.lang import Builder
from kivy.uix.label import Label
from kivy.clock import Clock
Builder.load_string("""
<MyLabel>
text: "{}: {}".format(self.title, self.value)
<UpdatingLabels>
GridLayout:
rows: 1
pos: 0, 0
size: root.size
MyLabel:
id: lb0
title: "value 0"
MyLabel:
id: lb1
title: "value 1"
MyLabel:
id: lb2
title: "value 2"
""")
class UpdatingLabels(Widget):
pass
class MyLabel(Label):
value = NumericProperty(0)
title = StringProperty('')
# This not working but the same what i wanna do
# In real case i have values genereted every second
# def clock_def(dt):
# MyLabel.ids.lb0.value += 1 # or MyLabel.ids.lb0.value = genereted_value_1
# MyLabel.ids.lb1.value += 2
# MyLabel.ids.lb2.value += 3
# event = Clock.schedule_interval(clock_def, 1)
class MyApp(App):
def build(self):
return UpdatingLabels()
if __name__ == '__main__':
MyApp().run()