How to terminate a TkinterApp correctly?

Gregor Lingl glingl at aon.at
Sat Aug 16 05:44:20 EDT 2003


I'm working on a windows machine

I've written a Tkinter-app (sort of game) which
consists mainly of an animation which is driven
by a while True: ... loop.

If I close the App's window by clicking the
right upper standard-X-Button, the program
doesn't terminate cleanly. Instead a somewhat
cryptic error message is displayed, e.g.:

....
TclError: invalid command name ".12880040.12880944"

which - I suppose - stems from the interpreter trying
to execute some statement in the infinite loop.

Only if this loop is terminated by some other means
- e.g. game over - before closing the window no
error message is displayed.

How, i.e. by what sort of event handler or error handler
can I avoid this annoying behaviour of my program?

Regards, Gregor





More information about the Python-list mailing list