The application is supposed to close when I click the close button for the main frame. But the way I implemented it, it quits with a Segmentation fault
when I click the button.
I worry about safe shutdown of the program, because I will need to persist stuff to disk later.
What is the proper non-violent way to terminate a WxPython application though a close button?
Here is the "main" loop of the program I implemented:
if __name__ == "__main__":
app = wx.App(False)
mf = MainFrame(None, title='Spectrum Checker') #subclasses frame
mf.register_close_callback( app.Destroy) #what is the apt func?
app.MainLoop()
Here is how it is implemented the callback within the MainFrame
:
def __init__(self, parent, title):
...
self.Bind(wx.EVT_CLOSE, self._when_closed)
...
def _when_closed(self, event):
if self.__close_callback__:
self.__close_callback__()