Thank you Rafeal, I forgot about that usage of metaclasses. It certainly
cleans things up for me. One thing of note is that the metaclass of QWidget
is not 'type', but 'pyqtWrapperType'. So the invocation should be...
pyqtWrapperType(name, (gui.QWidget,),{'spam':spam, 'yam': yam})
... or more
I think you can do something like this:
>>> import PyQt4.QtGui as gui
>>> def factory(name):
... def spam(): pass
... def yam(): pass
... return type(name, (gui.QWidget,),{'spam':spam, 'yam': yam})
...
>>> MyClass = factory('MyClass')
>>> MyClass.__mro__
(, , 'PyQt4.QtCore.QObject'>,
Does pyqt provide a way to override the class name when deriving a QObject
based class?
An example of why this is wanted:
def my_widget_class_factory(...):
class temp(QWidget):
...(dynamically generate class attributes and methods)
return temp
All classes generated by the above funct