Hello,
This seems like a trivial question, but I have been playing with this for awhile now. Currently I have a frame which is controlled by the aui manager. When I click on the X in the upper right hand corner of the window I want to have the user verify a few things before the application quits. I am using the wx.EVT_CLOSE and have tried the wx.EVT_WINDOW_DESTROY to route to a custom method to handle the event.
I can route the event to my function in which I prompt the user with some MessageDialogs. This is where the problem occurs. After a few seconds I get a prompt that my application is no longer responsive, and then quits. I tried simply detected the event and trying to skip it but what it comes down to is that when I click the X in the upper right hand corner it kills the program. So my question is, what is the proper way to handle this kind of closing, in such a way that I can cancel it if I don’t want to exit?
I have attached the function I call when I detect a wx.EVT_CLOSE.
def OnClose(self, evt):
dlg = wx.MessageDialog(None, msg, "Save File?", style=wx.YES_NO | wx.CANCEL | wx.ICON_EXCLAMATION | wx.STAY_ON_TOP)
selection = dlg.ShowModal()
if selection == wx.ID_YES:
self.saveDialog(pgIndex,2)
elif selection == wx.ID_CANCEL:
evt.Skip()
dlg.Destroy()
self.aui_mgr.UnInit()
del self.aui_mgr
self.Destroy()