]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/xrc/_xrc_ex.py
Little changes to match recent changes in wxWindows
[wxWidgets.git] / wxPython / contrib / xrc / _xrc_ex.py
1 #----------------------------------------------------------------------------
2 # The global was removed in favor of static accessor functions. This is for
3 # backwards compatibility:
4
5 TheXmlResource = XmlResource_Get()
6
7
8 #----------------------------------------------------------------------------
9 # Create a factory for handling the subclass property of the object tag.
10
11
12 def _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
20 class XmlSubclassFactory_Python(XmlSubclassFactory):
21 def __init__(self):
22 XmlSubclassFactory.__init__(self)
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
34 XmlResource_AddSubclassFactory(XmlSubclassFactory_Python())
35
36 #----------------------------------------------------------------------------