Hi all,
I am trying to let Task Coach behave in the face of a system shutdown or the user logging off, i.e. if there are any unsaved changes, give the user the option to save, not save, or cancel the shutdown/log-off.
Based on the documentation, I thought I had to bind wx.EVT_QUERY_END_SESSION and wx.EVT_END_SESSION, however event handlers for those two events are never invoked. You can experiment with the attached program if you like.
However, the handler for wx.EVT_CLOSE is called when I log off or try to shutdown the system. I can distinguish between a 'normal' close event and a shutdown event by asking the event whether it can be vetoed. Normal close events can and shutdown/log-off close events cannot. I thought a work around would be to simply not call event.Skip() for shutdown/log-off close events. This works, sort of: the shutdown/log-off is postponed until the user quits Task Coach. After quitting Task Coach, the shutdown or log-off continues!
By contrast, Firefox is able to really cancel a shutdown/log-off: if you have multiple tabs opened and try to log off, Firefox asks whether you want to close all tabs. If the user chooses cancel, the shutdown/log-off is canceled too.
So I guess my question is: is it possible to cancel a shutdown/log-off from a wxPython program?
Cheers, Frank
shutdown.py (1.39 KB)