]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_xrc_ex.py
docstring update
[wxWidgets.git] / wxPython / src / _xrc_ex.py
CommitLineData
d14a1e28 1#----------------------------------------------------------------------------
ce914f73
RD
2# The global was removed in favor of static accessor functions. This is for
3# backwards compatibility:
1e4a197e 4
d14a1e28 5TheXmlResource = XmlResource_Get()
1e4a197e
RD
6
7
d14a1e28 8#----------------------------------------------------------------------------
1e4a197e
RD
9# Create a factory for handling the subclass property of the object tag.
10
11
12def _my_import(name):
13 mod = __import__(name)
14 components = name.split('.')
15 for comp in components[1:]:
16 mod = getattr(mod, comp)
17 return mod
18
19
d14a1e28 20class XmlSubclassFactory_Python(XmlSubclassFactory):
1e4a197e 21 def __init__(self):
d14a1e28 22 XmlSubclassFactory.__init__(self)
1e4a197e
RD
23
24 def Create(self, className):
25 assert className.find('.') != -1, "Module name must be specified!"
26 mname = className[:className.rfind('.')]
27 cname = className[className.rfind('.')+1:]
28 module = _my_import(mname)
29 klass = getattr(module, cname)
30 inst = klass()
31 return inst
32
33
d14a1e28 34XmlResource_AddSubclassFactory(XmlSubclassFactory_Python())
1e4a197e 35
d14a1e28 36#----------------------------------------------------------------------------