How to terminate a TkinterApp correctly?

John Roth newsgroups at jhrothjr.com
Sat Aug 16 14:06:25 EDT 2003


"Michael Peuser" <mpeuser at web.de> wrote in message
news:bhlmgq$dqk$02$1 at news.t-online.com...
>
> ----- Original Message -----
> From: "Gregor Lingl" <glingl at aon.at>
> Newsgroups: comp.lang.python
> Sent: Saturday, August 16, 2003 3:53 PM
> Subject: Re: How to terminate a TkinterApp correctly?
>
> ....
>
> > 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,))
>
>
> Why don't you just return? The mainloop can handle everything!?

Unfortunately, the combination of Windows 9x (including Me)
and Python 2.1 can't handle everything. It may also be broken
in 2.2 and later, but I quit trying after reaching my frustration
limit. If you exit with an exception, something doesn't clean up
properly, and you break the DOS box and eventually Windows
itself when you try to shut down.

This problem doesn't exist in the Windows 2K (including XP)
code base, or other variants.

I don't know that it's ever been solved, but considering that
Windows 9x is gradually going away, it's also not a real hot
priority.

John Roth







More information about the Python-list mailing list