The protocol attribute in Tkinter allows one to run functions when the exit button of a window has been clicked (the button with the x on it, it’s top right in Windows).
I’d like to run a function when the user try’s to exit my application. Is there a wxPython equivalent?
snippet:
self.protocol("WM_DELETE_WINDOW", self.do_something)
When you click on the close button you are producing an
EVT_CLOSEevent so if you bind this event to anonClosemethod then you can execute whatever you want before actually closing the application. A simple example: