> A difference > (neutral) is not being able to derive from the module and avoid having > to add .ui to access the ui variables, but that doesn't look like a big > deal.
Yes you can :) (at least with some metaclass-hacking). I am using uic.loadUiType() for my project to not have to regenerate the .py-files each time and to avoid having too many often changing files in my subversion :) I attached the metaclass code :)... You only have to pay attention, that the .ui-file is named "AQtWindow.ui" :) Regards, Necoro
from PyQt4 import uic import sip class WindowMeta (sip.wrappertype, type): """This is the metaclass of all Qt-Windows. It automatically sets the correct base classes, so they do not have to be set by the programmer. @attention: The class has to have the same name as the .ui-file.""" def __new__ (cls, name, bases, dict): # parse UI new_bases = uic.loadUiType(UI_DIR+name+".ui") # all the base classes - e.g. (UI_AQtWindow, PyQt4.QtGui.QDialog) dict.update(_bases = new_bases) # only the Qt-Baseclass (like QDialog or QMainWindow) # the class has to later to a self._qt_base.__init__(...) dict.update(_qt_base = new_bases[1]) # create class return super(WindowMeta, cls).__new__(cls, name, new_bases+bases, dict) def __init__ (cls, name, bases, dict): b = dict["_bases"] del dict["_bases"] # init class super(WindowMeta, cls).__init__(name, b+bases, dict) class AQtWindow (object): __metaclass__ = WindowMeta def __init__ (self, parent): self._qt_base.__init__(self, parent) # the rest
_______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
