[wxPython] Re: Problems with OnCloseWindow for a wxPanel

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

Thanks it works! But only when I have one child object that need to catch the close event, but how should I do it when there's more than one?

Is it true that the EVT_CLOSE is only triggered once, ie. there's no reason to bind it on more than one wxWindow instance?? (hope you understood what I mean...)

- Jan -

···

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp