Since wxFrame has events that are handled by the app.MainLoop () function, the only way to get the wx.Frame () return value is to capture the event.
The standard practice of handling events usually occurs inside a class that comes from wx.Window itself (for example, Frame, Panel, etc.). Since you want the wx.Frame appearance code to receive the information gathered by processing the OnClose () event, the best way to do this is to register an event handler for your frame.
The documentation for wx.Window :: PushEventHandler is probably the best resource, and even the wxpython wiki contains a great article on how to do this. Inside the article, they register a custom handler that is an instance of "MouseDownTracker". Instead of creating an instance inside the PushEventHandler call, you must create it before the call to save the handle to the derived EventHandler class. That way, you can test your derived variables of the EventHandler class after the Frame has been destroyed or even let this derived class do special things for you.
Here is an adaptation of this code from a python wx file (admittedly a bit confusing due to the requirement of processing the results of a custom event using the "call" function):
import sys import wx import wx.lib.newevent (MyCustomEvent, EVT_CUSTOM) = wx.lib.newevent.NewEvent() class CustomEventTracker(wx.EvtHandler): def __init__(self, log, processingCodeFunctionHandle): wx.EvtHandler.__init__(self) self.processingCodeFunctionHandle = processingCodeFunctionHandle self.log = log EVT_CUSTOM(self, self.MyCustomEventHandler) def MyCustomEventHandler(self, evt): self.log.write(evt.resultOfDialog + '\n') self.processingCodeFunctionHandle(evt.resultOfDialog) evt.Skip() class MyPanel2(wx.Panel): def __init__(self, parent, log): wx.Panel.__init__(self, parent) self.log = log def OnResults(self, resultData): self.log.write("Result data gathered: %s" % resultData) class MyFrame(wx.Frame): def __init__(self, parent, ID = -1, title = "", pos = wx.DefaultPosition, size = wx.DefaultSize, style = wx.DEFAULT_FRAME_STYLE): wx.Frame.__init__(self, parent, ID, title, pos, size, style) self.panel = panel = wx.Panel(self, -1, style = wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN | wx.FULL_REPAINT_ON_RESIZE) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add((25, 25)) row = wx.BoxSizer(wx.HORIZONTAL) row.Add((25,1)) m_close = wx.Button(self.panel, wx.ID_CLOSE, "Close") m_close.Bind(wx.EVT_BUTTON, self.OnClose) row.Add(m_close, 0, wx.ALL, 10) sizer.Add(row) self.panel.SetSizer(sizer) def OnClose(self, evt): dlg = wx.MessageDialog(self, "Do you really want to close this frame?", "Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION) result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_CANCEL: event = MyCustomEvent(resultOfDialog = "User Clicked CANCEL") self.GetEventHandler().ProcessEvent(event) else: # result == wx.ID_OK event = MyCustomEvent(resultOfDialog = "User Clicked OK") self.GetEventHandler().ProcessEvent(event) self.Destroy() app = wx.App(False) f2 = wx.Frame(None, title="Frame 1 (for feedback)", size=(400, 350)) p2 = MyPanel2(f2, sys.stdout) f2.Show() eventTrackerHandle = CustomEventTracker(sys.stdout, p2.OnResults) f1 = MyFrame(None, title="PushEventHandler Tester (deals with on close event)", size=(400, 350)) f1.PushEventHandler(eventTrackerHandle) f1.Show() app.MainLoop()