]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/contrib/xrc/_xrcextras.py
fix text scrolling in GTK2 (patch 703988)
[wxWidgets.git] / wxPython / contrib / xrc / _xrcextras.py
index e4cd16f5621d45962958b47f6a00da60fa1c96f8..9562aea2eb7a3bcfef04d54980c31ca4391d50b4 100644 (file)
@@ -4,3 +4,35 @@
 wxTheXmlResource = wxXmlResource_Get()
 
 wx.wxXmlNodePtr = wxXmlNodePtr
+
+
+
+
+#----------------------------------------------------------------------
+#  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 wxXmlSubclassFactory_Python(wxXmlSubclassFactory):
+    def __init__(self):
+        wxXmlSubclassFactory.__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
+
+
+wxXmlResource_AddSubclassFactory(wxXmlSubclassFactory_Python())
+