XRC and dynamically created widgets?
John Salerno
johnjsal at NOSPAMgmail.com
Mon Oct 2 16:30:56 PDT 2006
Robin Dunn wrote:
> 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').
>
Thanks! Makes perfect sense. I was even beginning to suspect something
like this.
More information about the wxpython-users
mailing list