[wxPython] Problems with OnCloseWindow for a wxPanel

Hi!

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??

I hope you could help me on this one!

    - Jan -

#--sample code
from wxPython.wx import *

class myPanel(wxPanel):

  def __init__(self,parent):
    wxPanel.__init__(self,parent,-1)
    wxStaticText(self,-1,'The text')
    EVT_CLOSE(self,self.OnCloseWindow)

  def OnCloseWindow(self,event):
    # THIS METHOD IS NEVER CALLED!!
    print 'panel closed'
    event.Skip()

class myFrame(wxFrame):

  def __init__(self,parent):
    wxFrame.__init__(self,parent,-1,'title')
    myPanel(self)
    EVT_CLOSE(self,self.OnCloseWindow)

  def OnCloseWindow(self,event):
    print 'frame closed'
    event.Skip()

class MainApp(wxApp):
  def OnInit(self):
    frame = myFrame(NULL)
    frame.Show(true)
    return true

if __name__ == '__main__':
  app = MainApp(0)
  app.MainLoop()

···

#----------#

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

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??

Because only frames and dialogs are "closed" (IOW, possibly have a close
button and a close method.)

You might try EVT_WINDOW_DESTROY instead.

···

--
Robin Dunn
Software Craftsman
robin@AllDunn.com Java give you jitters?
http://wxPython.org Relax with wxPython!