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/>
<<image002.png>>
_______________________________________________ Tkinter-discuss mailing list [email protected] http://mail.python.org/mailman/listinfo/tkinter-discuss
