[wxPython-users] xrc TreeCtrl EVT_WINDOW_CREATE is not launched
Robin Dunn
robin at alldunn.com
Mon Aug 21 09:28:43 PDT 2006
Christian Kristukat wrote:
> Hi,
> I want to subclass a TreeCtrl using xrc and I'm doing this with the usual two
> step creation method:
>
> class TreeCtrl(wx.TreeCtrl):
> def __init__(self):
> pre = wx.PreTreeCtrl()
> self.PostCreate(pre)
> self.Bind(wx.EVT_WINDOW_CREATE, self.OnCreate)
>
> def OnCreate(self, event):
> self.Unbind(wx.EVT_WINDOW_CREATE)
> wx.CallAfter(self._PostInit)
> event.Skip()
> return True
>
> def _PostInit(self):
> pass
>
> This works fine on linux but on windows, the WINDOW_CREATE event does not happen
> and thus the post creation code is not executed (both python 2.4 wxPython
> 2.6.3.3). Every other control I subclassed so far, using the appropriate
> wx.PreXXXCtrl() method, does not have this problem. What can I do to have that
> event launched?
I've had this problem with native widgets on Windows before. The issue
is that in order for window messages to be sent to the wx WndProc where
they can be turned into wx Events, the native window first needs to be
"subclassed" (in the Windows API sense) but for the native controls that
can't happen until after the creation is done. IIRC there was some
workaround checked in recently for 2.7 but I don't know any details
about the change or if it can be backported to 2.6.
If the above is all you are doing in the create handler then I think I
would just try moving the wx.CallAfter(self._PostInit) to the __init__
and see if that does what you need.
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list