How to terminate a TkinterApp correctly?

Gregor Lingl glingl at aon.at
Sat Aug 16 15:53:47 CEST 2003


Michael Peuser schrieb:

> "Gregor Lingl" <glingl at aon.at> schrieb im Newsbeitrag
> news:3F3DFCF4.5020109 at aon.at...
> 
>>I'm working on a windows machine
>>
>>I've written a Tkinter-app ...
> 

Thanks for your remarks and your example. The
following solution finally did it:

def exit():
     global done
     done = True # so the animation will terminate, but
                 # not immediately! The actual pass through
                 # the loop has to be finished.
     print "done!"
     import sys
     # after_idle seems to be crucial! Waits for terminating
     # the loop (which is in a callback function)
     cv.after_idle(sys.exit, (0,))

cv.master.protocol("WM_DELETE_WINDOW", exit)

if not usingIDLE:
     root.mainloop()

Regards, Gregor





More information about the Python-list mailing list