XMLResource.LoadFromString expansion

Aaron Brady wrote:

···

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Wednesday, January 16, 2008 6:39 PM

Aaron Brady wrote:

-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Friday, January 11, 2008 2:54 PM

  sizer = XRCCTRL(self, 'widgetName').GetContainingSizer()

Why does XRCCTRL require the object -and- name? Does it load a new

instance

of the control? Does it go back and find it in the original file?

def XRCID(str_id, value_if_not_found = wx.ID_NONE):
     return XmlResource_GetXRCID(str_id, value_if_not_found)

def XRCCTRL(window, str_id, *ignoreargs):
     return window.FindWindowById(XRCID(str_id))

Names are guaranteed to be unique throughout an XRC file.

No, they are not. For example, it is perfectly acceptable, and often desirable) to have multiple dialogs in an XRC file, each with a widget named "wxID_OK". Also there is nothing that prevents you from having multiple widgets within the same top-level window with the same name, (children of different Panels within the same Frame, for example,) although it probably isn't a good idea to do so.

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