I'm new to Kivy, and new to GUIs, but not new to programming.
I've got a project where I'll be receiving some socket data, and I want to update Label and/or Button text with some dynamic information.
In order to simulate that, I have a Thread that will kick off a text change about 5 seconds later, so I can have a look.
I've look everywhere for examples that dynamically change Label text, but everything is originating from an event, such as a button click; my code will need to update on the arrival of new data, and be pushed to the screen.
I thought I might have to 'repaint' or 'refresh' (my words, don't know the right thing here) the GUI to get the new text up, but I can't figure out how to do that, or even know if that's what I need to do!
=========py code=======
import time
from threading import Thread
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.label import Label
from kivy.properties import ObjectProperty, StringProperty
class Box_a(BoxLayout):
pass
class Label_a(Label):
display_text = StringProperty("Banjos Rule!")
def chgText(self):
time.sleep(5)
print("changing text")
print(self.display_text)
self.display_text = "Fiddle ain't bad!"
print("changed text")
print(self.display_text)
class Simple2(App):
def build(self):
return Box_a()
def main():
th = Thread(target=Label_a().chgText)
th.start()
b = Simple2()
b.run()
return 0
if __name__ == '__main__':
main()
============kv code============
<Box_a>:
Label_a:
text: "My label is " + self.display_text