1 #!/usr/bin/env python 2 3 from qt import * 4 import qtxmldom 5 6 class Factory: 7 def __init__(self, ui_filename): 8 self.ui = qtxmldom.parse(ui_filename) 9 10 def findWidget(self, widget_class, name): 11 for widget in self.ui.getElementsByTagName("widget"): 12 if widget.getAttribute("class") == widget_class: 13 for property in widget.getElementsByTagName("property"): 14 if property.getAttribute("name") == "name": 15 for cstring in property.getElementsByTagName("cstring"): 16 cstring.normalize() 17 found_name = cstring.childNodes[0].nodeValue 18 if found_name == name: 19 return widget 20 return None 21 22 # vim: tabstop=4 expandtab shiftwidth=4