[Tkinter-discuss] Threading issue with Tkinter Frame.insert
Moray Grieve
mbg at progress.com
Fri Sep 18 12:00:16 CEST 2009
The code fragment below has an example where a Tk GUI is launched as a
separate 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;
self.messageBoxDetails.insert(INSERT, "Hello world")
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 see any related issues to this and wonder if this is a bug in
the 2.6 Tkinter module?
Thanks for any assistance.
-Moray
---------------------
import time, thread
from Tkinter import *
class ExampleError:
def __init__(self):
self.parentContainer = Tk()
self.parentContainer.protocol('WM_DELETE_WINDOW',
self.quitPressed)
self.parentContainer.wm_geometry("500x400")
self.parentContainer.title("Parent Container Title")
self.container = Frame(self.parentContainer)
self.messageBoxDetails = Text(self.container, wrap=WORD,
width=1, height=1, padx=10, pady=10)
# in python 2.6, this next statement hangs when running as a
thread - note that
# inserting an empty string works though
self.messageBoxDetails.insert(INSERT, "d")
self.messageBoxDetails.pack(fill=BOTH, expand=YES, side=LEFT)
self.container.pack(fill=BOTH, expand=YES, padx=5, pady=5)
def quitPressed(self):
self.stop()
def start(self):
self.parentContainer.mainloop()
def stop(self):
self.parentContainer.quit()
self.parentContainer.destroy()
if __name__ =="__main__":
example = ExampleError()
time.sleep(1)
thread.start_new_thread(example.start, ())
time.sleep(5) <http://www.progress.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20090918/db58d291/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 174 bytes
Desc: image002.png
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20090918/db58d291/attachment.png>
More information about the Tkinter-discuss
mailing list