I’m working on an application which requires dynamic loading of panels containing similar elements.
For that I have created different element panels in XRCED which can be dynamically loaded in my python application.
Unfortunately when I load a panel from an xrc file, the ID’s assigned to the GUI elements stay the same.
As such I cannot bind a function (or different functions) to these elements on different panels, as the XRC-ID of an element stays the same for every panel that I load (namely the ID which is defined in the XRC file).
It sounds a bit twisted, but if you look at the example below it should be clear what I’m trying to do.
Is there a way I can load my panel from the XRC file and change the ID of the GUI elements defined in the XRC file?
Best regards,
Tom.
As for an example:
···
==============
Say, I have an XRC file which contains a panel and the panel has a button with XRC-ID “newButton”
In my python main-application I have a button “Add Panel” which adds the panel described in the XRC file mentioned above.
For the first panel which is added by pushing “Add Panel” I want the button with XRC-ID “newButton” to trigger a function OnNewButtonOne
For the second panel which is added by pushing “Add Panel” I want the button with XRC-ID “newButton” to trigger a function OnNewButtonTwo
If I could change the XRC-ID “newButton” to for example “newBotton1” immediately after loading the panel, I can bind it to OnNewButtonOne
For the second panel which is loaded I would then changen the XRC-ID “newButton” to “newButton2” and I can bind it to OnNewButtonTwo
Hi all,
I'm working on an application which requires dynamic loading of panels containing similar elements.
For that I have created different element panels in XRCED which can be dynamically loaded in my python application.
Unfortunately when I load a panel from an xrc file, the ID's assigned to the GUI elements stay the same.
As such I cannot bind a function (or different functions) to these elements on different panels, as the XRC-ID of an element stays the same for every panel that I load (namely the ID which is defined in the XRC file).
It sounds a bit twisted, but if you look at the example below it should be clear what I'm trying to do.
Is there a way I can load my panel from the XRC file and change the ID of the GUI elements defined in the XRC file?
Best regards,
Tom.
==============
Say, I have an XRC file which contains a panel and the panel has a button with XRC-ID "newButton"
In my python main-application I have a button "Add Panel" which adds the panel described in the XRC file mentioned above.
For the first panel which is added by pushing "Add Panel" I want the button with XRC-ID "newButton" to trigger a function OnNewButtonOne
For the second panel which is added by pushing "Add Panel" I want the button with XRC-ID "newButton" to trigger a function OnNewButtonTwo
If I could change the XRC-ID "newButton" to for example "newBotton1" immediately after loading the panel, I can bind it to OnNewButtonOne
For the second panel which is loaded I would then changen the XRC-ID "newButton" to "newButton2" and I can bind it to OnNewButtonTwo
The XRCCTRL and XRCID helper functions are essentially doing a FindWindowByName starting with the window passed to them. So if you are passing a common parent of the panels then the duplicates will be a problem. On the other hand if you use XRCCTRL(panel1, "newButton) and XRCCTRL(panel2, "newButton") then you should be getting the two individual buttons.
You'll need to do something similar when binding events. IOW, bind to the panels or the buttons themselves, not to the common parent.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!