]> git.saurik.com Git - wxWidgets.git/blob - wxPython/contrib/xrc/_xrcextras.py
Lots of changes for wxPython to start using many of the new featues in
[wxWidgets.git] / wxPython / contrib / xrc / _xrcextras.py
1
2 # The global was removed in favor of static accessor functions. This is for
3 # backwards compatibility:
4 wxTheXmlResource = wxXmlResource_Get()
5
6 wx.wxXmlNodePtr = wxXmlNodePtr
7
8
9
10
11 #----------------------------------------------------------------------
12 # Create a factory for handling the subclass property of the object tag.
13
14
15 def _my_import(name):
16 mod = __import__(name)
17 components = name.split('.')
18 for comp in components[1:]:
19 mod = getattr(mod, comp)
20 return mod
21
22
23 class wxXmlSubclassFactory_Python(wxXmlSubclassFactory):
24 def __init__(self):
25 wxXmlSubclassFactory.__init__(self)
26
27 def Create(self, className):
28 assert className.find('.') != -1, "Module name must be specified!"
29 mname = className[:className.rfind('.')]
30 cname = className[className.rfind('.')+1:]
31 module = _my_import(mname)
32 klass = getattr(module, cname)
33 inst = klass()
34 return inst
35
36
37 wxXmlResource_AddSubclassFactory(wxXmlSubclassFactory_Python())
38