Generate new IDs for an xrc Panel?

Hi everyone,

I have an xrc Panel with child controls that I would like to load several times in the same Frame, yet the IDs turn out each time to be the same. Is there any way to have the wxPython IDs be different for different xrc.LoadPanel calls?

Thanks,

Lee

Lee Merrill wrote:

Hi everyone,
     I have an xrc Panel with child controls that I would like to load several times in the same Frame, yet the IDs turn out each time to be the same. Is there any way to have the wxPython IDs be different for different xrc.LoadPanel calls?

No. However you could design your app so the things that need to deal with the IDs are localized into a class instance specific to each panel. If all of the relevant events are caught and handled there then you wouldn't have to worry about ID confusion at higher levels in the containment hierarchy.

···

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

Thanks, Robin, what I'm doing now is fish up all the sub-controls under the Panel I am adding, and assign a unique custom ID with some unlikely name for the ID, to each control (i.e.: ctrl.myCustomAppId = NextId; NextId += 1). A bit kludgey, but I'd rather not subclass all the controls in these Panels. This sure does make the .xrc file a lot smaller! Not to mention easier to edit...

Lee

···

----- Original Message ----- From: "Robin Dunn" <robin@alldunn.com>
To: <wxPython-users@lists.wxwidgets.org>
Sent: Saturday, August 12, 2006 1:43 PM
Subject: Re: [wxPython-users] Generate new IDs for an xrc Panel?

Lee Merrill wrote:

Hi everyone,
I have an xrc Panel with child controls that I would like to load several times in the same Frame, yet the IDs turn out each time to be the same. Is there any way to have the wxPython IDs be different for different xrc.LoadPanel calls?

No. However you could design your app so the things that need to deal with the IDs are localized into a class instance specific to each panel. If all of the relevant events are caught and handled there then you wouldn't have to worry about ID confusion at higher levels in the containment hierarchy.

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

Lee Merrill wrote:

Thanks, Robin, what I'm doing now is fish up all the sub-controls under the Panel I am adding, and assign a unique custom ID with some unlikely name for the ID, to each control (i.e.: ctrl.myCustomAppId = NextId; NextId += 1). A bit kludgey, but I'd rather not subclass all the controls in these Panels. This sure does make the .xrc file a lot smaller! Not to mention easier to edit...

No need to subclass the controls. I just meant to encapsulate everything that needs to deal with the IDs of the contents of the panel in the class for the panel itself. Then if you have multiple instances of that panel it won't matter if the contents have the same IDs or not, because all the handlers for those widgets are contained in the panel.

···

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

I see, Bind the events to a class with a subclass of Panel, that's a good idea, and cleaner too, assuming that making a class out of an xrc Panel is not so difficult, which I am now off to find out.

Thanks,
Lee

···

----- Original Message ----- From: "Robin Dunn" <robin@alldunn.com>
To: <wxPython-users@lists.wxwidgets.org>
Sent: Saturday, August 12, 2006 5:14 PM
Subject: Re: [wxPython-users] Generate new IDs for an xrc Panel?

Lee Merrill wrote:

Thanks, Robin, what I'm doing now is fish up all the sub-controls under the Panel I am adding, and assign a unique custom ID ...

No need to subclass the controls. I just meant to encapsulate everything that needs to deal with the IDs of the contents of the panel in the class for the panel itself. Then if you have multiple instances of that panel it won't matter if the contents have the same IDs or not, because all the handlers for those widgets are contained in the panel.

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