# HG changeset patch # User paulb # Date 1130167668 0 # Node ID 06fa756dd5c65d802165b581ded0e49f98cac4fc # Parent 4dcdbd08302069e6507d08317ccb5af7b9f8d924 [project @ 2005-10-24 15:27:48 by paulb] Added an application directory for the Qt Designer example. diff -r 4dcdbd083020 -r 06fa756dd5c6 examples/Common/QtConfigurator/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/Common/QtConfigurator/__init__.py Mon Oct 24 15:27:48 2005 +0000 @@ -0,0 +1,58 @@ +import QtConfigurator.Forms +#import factory +import qtui +import os + +class Configurator(QtConfigurator.Forms.Configurator): + + resource_dir = os.path.join(os.path.split(__file__)[0], "Resources") + ui_filename = os.path.join(resource_dir, "config.ui") + ui_hard_disks_filename = os.path.join(resource_dir, "config_hard_disks.ui") + + def __init__(self, *args, **kw): + QtConfigurator.Forms.Configurator.__init__(self, *args, **kw) + #self.factory = factory.Factory(self.ui_filename) + + def baseSystemChanged(self): + print self.base_system.currentItem() + + def addHardDisk(self): + hard_disks = qtui.QWidgetFactory.create(self.ui_hard_disks_filename) + print str(hard_disks.name()) + #top = qtui.QWidgetFactory.create(self.ui_filename) + #print [str(c.name()) for c in top.children()] + #hard_disks = top.child("hard_disks") + print [str(c.name()) for c in hard_disks.children()] + tab_pages = hard_disks.child("tab pages") + print [str(c.name()) for c in tab_pages.children()] + tab = tab_pages.child("tab") + self.hard_disks.addTab(tab, hard_disks.tabLabel(tab)) + + def addMemoryUnit(self): + print "configuration.addMemoryUnit(): Not implemented yet" + + def addStorageUnit(self): + print "configuration.addStorageUnit(): Not implemented yet" + + def removeHardDisk(self): + page = self.hard_disks.currentPage() + self.hard_disks.removePage(page) + del page + + def removeMemoryUnit(self): + page = self.memory_units.currentPage() + self.memory_units.removePage(page) + del page + + def removeStorageUnit(self): + page = self.storage_units.currentPage() + self.storage_units.removePage(page) + del page + + def updateConfig(self): + print "configuration.updateConfig(): Not implemented yet" + + def exportConfig(self): + print "configuration.exportConfig(): Not implemented yet" + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 4dcdbd083020 -r 06fa756dd5c6 examples/Common/QtConfigurator/factory.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/Common/QtConfigurator/factory.py Mon Oct 24 15:27:48 2005 +0000 @@ -0,0 +1,22 @@ +#!/usr/bin/env python + +from qt import * +import qtxmldom + +class Factory: + def __init__(self, ui_filename): + self.ui = qtxmldom.parse(ui_filename) + + def findWidget(self, widget_class, name): + for widget in self.ui.getElementsByTagName("widget"): + if widget.getAttribute("class") == widget_class: + for property in widget.getElementsByTagName("property"): + if property.getAttribute("name") == "name": + for cstring in property.getElementsByTagName("cstring"): + cstring.normalize() + found_name = cstring.childNodes[0].nodeValue + if found_name == name: + return widget + return None + +# vim: tabstop=4 expandtab shiftwidth=4