__del__() in a Tkinter app
fredrik at effbot.org
Sat Dec 16 14:03:53 CET 2000
> I have tried adding a __del__() method to a Tkinter application so it can
> remove temporary files when the program exits.
Don't ever do things like that in a __del__ method. Python isn't
C++, and doesn't make any guarantees that __del__ methods will
ever be called.
To properly shut down a Tkinter application, bind the "<Destroy>"
event on the root/toplevel window.
You can also overload the destroy method:
def __init__(self, ...):
# not really needed in 2.0 and later, but it doesn't hurt
... handle shutdown
More information about the Python-list