2

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.

Hope
  • 33
  • 4

1 Answers1

1

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.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • Yes, you're right. I just searched more. (my English is not very good) and find a relative topic: http://stackoverflow.com/questions/3567238/i-need-a-little-help-with-python-tkinter-and-threading – Hope Jul 05 '13 at 04:15