Using maskededit controls with xrc and wxpython

Robin Dunn wrote:

Will Sadkin wrote:

Robin Dunn wrote:

Here is a basic recipie just off the top of my head.

[...]

Should this discussion move to wxPython-dev?

Probably a good idea.

Ok, I've made some experimental changes to the masked edits, but
now I want to test them. It occurs to me that none of the XRC examples
show how to get object references for the constructed controls after
they've been "loaded". Without this, the demos seem incomplete to
me; for the simple multi-control panel in the demo, how would one
ever use the resulting controls, set up event handlers, get values
out of them, etc? To set up masked edits, one would presumably
want to do so in the panel's create handler, so that one could
then call SetParameters on them, to set up all the mask-specific
attributes. How does one grab the references to do this properly?

/Will Sadkin

Will Sadkin wrote:

Robin Dunn wrote:

Will Sadkin wrote:

Robin Dunn wrote:

Here is a basic recipie just off the top of my head.

[...]

Should this discussion move to wxPython-dev?

Probably a good idea.

Ok, I've made some experimental changes to the masked edits, but
now I want to test them. It occurs to me that none of the XRC examples
show how to get object references for the constructed controls after they've been "loaded". Without this, the demos seem incomplete to me; for the simple multi-control panel in the demo, how would one
ever use the resulting controls, set up event handlers, get values out of them, etc? To set up masked edits, one would presumably
want to do so in the panel's create handler, so that one could then call SetParameters on them, to set up all the mask-specific attributes. How does one grab the references to do this properly?

There are some helper functions in the xrc module for this:

  def XRCID(str_id):
      return XmlResource_GetXRCID(str_id)

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

So if you have a panel generated from XRC and you want to get a reference to a field named "foo" in the xml, then you could do this:

  foo = XRCCTRL(panel, "foo")

ยทยทยท

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