I'm trying to update the text of a label from a Thread but it doesn't work. Here is a sample of the code
def search_callback():
class Holder(object):
done = False
holder = Holder()
t = threading.Thread(target=animate, args=(holder,))
t.start()
#long process here
holder.done = True # inform thread long process is finished
def animate(holder):
for c in itertools.cycle(['|', '/', '-', '\\']):
if holder.done:
break
print('\rRecherche ' + c) # This work!
label_wait.configure(text='\rRecherche ' + c) # this doesn't work nothing appear in my label
time.sleep(0.5)
label_wait.configure(text='\rTerminé! ')
print('\rTerminé! ')
But I don't understand why the label_wait.configure
doesn't work also print
works well.
I've tried to use after
method in my thread but it's doesn't change.