+ if self.subclass: name = self.subclass + '(' + self.className + ')'
+ name = self.className
+ if self.ref: name = 'ref: ' + self.ref + ', ' + name
+ return name
+ # Sets name of tree object
+ def setTreeName(self, name):
+ if self.hasChild: obj = self.child
+ else: obj = self
+ obj.name = name
+ obj.element.setAttribute('name', name)
+
+# Imitation of FindResource/DoFindResource from xmlres.cpp
+def DoFindResource(parent, name, classname, recursive):
+ for n in parent.childNodes:
+ if n.nodeType == minidom.Node.ELEMENT_NODE and \
+ n.tagName in ['object', 'object_ref'] and \
+ n.getAttribute('name') == name:
+ cls = n.getAttribute('class')
+ if not classname or cls == classname: return n
+ if not cls or n.tagName == 'object_ref':
+ refName = n.getAttribute('ref')
+ if not refName: continue
+ refNode = FindResource(refName)
+ if refName and refNode.getAttribute('class') == classname:
+ return n
+ if recursive:
+ for n in parent.childNodes:
+ if n.nodeType == minidom.Node.ELEMENT_NODE and \
+ n.tagName in ['object', 'object_ref']:
+ found = DoFindResource(n, name, classname, True)
+ if found: return found
+def FindResource(name, classname='', recursive=True):
+ found = DoFindResource(g.tree.mainNode, name, classname, recursive)
+ if found: return found
+ wxLogError('XRC resource "%s" not found!' % name)
+