You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The attached file has an example where a Tk GUI is launched as a
seperate thread - this all works fine in Python 2.5, but in Python 2.6
the thread hangs.
Comment this line out, or use an empty string rather than "Hello World",
and the example works in both Python 2.5 and Python 2.6. I have not been
able to seen any related issues to this and wonder if this is a bug in
the 2.6 Tkinter module.
Quoting from msg179101 on bpo-16823, which I turned into a doc issue:
'''
What you are doing appears to be unsupported (invalid). From http://www.astro.washington.edu/users/rowen/TkinterSummary.html
"all Tkinter access must be from the main thread (or more precisely,
from the thread that calls the mainloop). Violating this is likely to
cause nasty and mysterious symptoms such as freezes and core dumps."
'''
You got the freeze part. I suspect what changed from 2.5 to 2.6 was the tcl/tk version delivered with Python on Windows.
I changes the import to theading instead of thread and the start line to
threading.Thread(target=example)
On 3.7 with tcl/tk 8.6 with thread support, I see the gui when mainloop is called in the thread, and then the >>> prompt appears. On 2.7 with tk 8.5 without thread support, I see no hang but only >>>, no box, after the same time delay.
With thread support, thread calls work. Without, success varies, and so do failure modes. See bpo-33479 for proposed doc on tkinter and thread safety.
Activity
moraygrieve commentedon Sep 17, 2009
The attached file has an example where a Tk GUI is launched as a
seperate thread - this all works fine in Python 2.5, but in Python 2.6
the thread hangs.
The issue seems to be in the line;
Comment this line out, or use an empty string rather than "Hello World",
and the example works in both Python 2.5 and Python 2.6. I have not been
able to seen any related issues to this and wonder if this is a bug in
the 2.6 Tkinter module.
moraygrieve commentedon Sep 17, 2009
I should say this is running on Windows XP
RamchandraApte commentedon Nov 3, 2012
Bump.
serhiy-storchaka commentedon Jan 15, 2013
Tkinter as perhaps any other GUI library must be used only from one thread.
terryjreedy commentedon Mar 8, 2013
Quoting from msg179101 on bpo-16823, which I turned into a doc issue:
'''
What you are doing appears to be unsupported (invalid). From
http://www.astro.washington.edu/users/rowen/TkinterSummary.html
"all Tkinter access must be from the main thread (or more precisely,
from the thread that calls the mainloop). Violating this is likely to
cause nasty and mysterious symptoms such as freezes and core dumps."
'''
You got the freeze part. I suspect what changed from 2.5 to 2.6 was the tcl/tk version delivered with Python on Windows.
terryjreedy commentedon May 13, 2018
With thread support, thread calls work. Without, success varies, and so do failure modes. See bpo-33479 for proposed doc on tkinter and thread safety.