How to make tkinter execution in function fix()
wait till label's
text get chnaged and then print end
.
Current working: When I click the sub
button, new thread gets created and for
loop gets executed. After 10000000 loops, my label would change to 9999999
. But before my label changes, tkinter prints end
.
I tried t.join()
, but it freezes the GUI.
import tkinter as tk
from tkinter import ttk
import threading
root = tk.Tk()
label = tk.Label(text='vinoth')
label.pack()
def fix():
a=0
t = threading.Thread(target=count, args=(a,))
t.start()
#t.join()
print('end')
def count(a):
for i in range(0,10000000):
a=i
label['text'] = a
button = tk.Button(text='sub', command=fix)
button.pack()
dropdown = ttk.Combobox()
dropdown.pack()
root.mainloop()