Reputation: 43
I'm a beginner at Tkinter. Yesterday, when I try to start a message box in a thread function, but it failed and stuck. I didn't find any useful information about this problem, so I asked here:
from tkinter import *
from threading import Thread
def func():
messagebox.askyesno()
t = Thread(target=func)
Label(text='Hello').pack()
t.start()
mainloop()
No error. it just doesn't work. I also find that any dialog can not be created in the thread procedure.
Thanks for any help, or useful information.
Upvotes: 3
Views: 2227
Reputation: 385970
You cannot call a tkinter widget method from any thread other than the one it was created in, and you can only ever create widgets in a single thread.
Upvotes: 1