Multithreading tkinter question

Eric Brunel eric_brunel at despammed.com
Fri Dec 17 03:48:49 EST 2004


Oleg Paraschenko wrote:
[snip]
> In my case "Hello" works and "Quit" doesn't (GUI stays frozen).
> Linux, Python 2.3.3, pygtk-0.6.9.

That's not a multithreading issue, but just the way the quit method works. Try:

-------------------------------------------------
import time
from Tkinter import *

root = Tk()
b = Button(root, text='Quit')
b.configure(command=root.quit)
b.pack()

root.mainloop()

time.sleep(2)
-------------------------------------------------

When you click the "Quit" button, the GUI stays there until the time.sleep ends. 
root.quit just goes out of the mainloop; it doesn't destroy the widgets. To do 
that, you have to add an explicit root.destroy() after root.mainloop()
-- 
- Eric Brunel <eric (underscore) brunel (at) despammed (dot) com> -
PragmaDev : Real Time Software Development Tools - http://www.pragmadev.com



More information about the Python-list mailing list