wxWidgets/wxPython/src/_xrc_ex.py
Robin Dunn 38b97c15ac Moved xrc out of contrib and into the core source dir, just like in
C++.  It will now always be built.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29280 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2004-09-23 16:49:01 +00:00

37 lines
1.1 KiB
Python

#----------------------------------------------------------------------------
# The global was removed in favor of static accessor functions. This is for
# backwards compatibility:
TheXmlResource = XmlResource_Get()
#----------------------------------------------------------------------------
# Create a factory for handling the subclass property of the object tag.
def _my_import(name):
mod = __import__(name)
components = name.split('.')
for comp in components[1:]:
mod = getattr(mod, comp)
return mod
class XmlSubclassFactory_Python(XmlSubclassFactory):
def __init__(self):
XmlSubclassFactory.__init__(self)
def Create(self, className):
assert className.find('.') != -1, "Module name must be specified!"
mname = className[:className.rfind('.')]
cname = className[className.rfind('.')+1:]
module = _my_import(mname)
klass = getattr(module, cname)
inst = klass()
return inst
XmlResource_AddSubclassFactory(XmlSubclassFactory_Python())
#----------------------------------------------------------------------------