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