[wxPython] Re: Problems with OnCloseWindow for a wxPanel

I have some problems catching the OnCloseWindow event on

children(wxPanels)

of a wxFrame.

The problem is that the OnCloseWindow on the child-panels is never called!
Why??

Unless you override the EVT_CLOSE for the frame that is closing, you won't
catch the event because the default behavior does not loop through its
children. What I've done in is find the closest wxFramePtr derived object
by iteratively calling self.GetParent()

<snip>
        parent = self
        while parent:
            if issubclass(parent.__class__, wx.wxFramePtr):
                wx.EVT_CLOSE(parent, self.OnCloseWindow)
            parent = parent.GetParent()
</snip>

Hope that helps. Not as elegant as one might wish, but it works... :wink:
-Shane Holloway

···

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com