[wxPython-users] Re: XRC and dynamically created widgets?
Robin Dunn
robin at alldunn.com
Mon Oct 2 14:51:48 PDT 2006
John Salerno wrote:
> John Salerno wrote:
>
>> self.frame.Bind(wx.EVT_MENU, self.OnNewPage,
>> id=xrc.XRCID('newRecordMenuItem'))
>
> One more quickie question: why does this line have to be written this
> way, with the id keyword argument, instead of like:
>
> xrc.XCRCTRL(self.XXX, 'new RecordMenuItem')
>
> Doesn't the Bind() method take a reference to the object as its third
> parameter?
Yes, but xrc.XCRCTRL doesn't know how to return a wx.MenuItem, only
things that derive from wx.Window. Technically the 3rd parameter can be
anything that has a GetId() method, and GetId is what is called if it is
passed, otherwise the value of the id parameter is used to make the
connection between the source and target of the event.
> And why is the 'id' necessary? It didn't work when I left it
> out.
Because in this case you want to pass a value for the 4th parameter
(named 'id') and not the 3rd (named 'source').
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!
More information about the wxpython-users
mailing list