[PyQt] staticMetaObject

Kermit stef.kermit at gmail.com
Thu Mar 29 12:44:06 BST 2012


Hi PyQt community,

i can't understand why staticMetaObject isn't know in __new__ construction

first step, i think is because staticMetaObject is create for instance,
but in this code bellow, staticMetaObject is know before real instanciation

no way for work with in __new__ function ?

Thx for your help
Kermit

"""
from PyQt4 import QtCore

class MetaKlass(QtCore.pyqtWrapperType):
    def __new__(meta_cls, name, bases, cls_dict):
        cls = QtCore.pyqtWrapperType.__new__(meta_cls, name, bases,
cls_dict)
        try:
            meta = cls.staticMetaObject
            print "__new__", meta
        except:
            print "error for __new__"
        return cls

    def __call__(cls, *args, **kwargs):
        try:
            meta = cls.staticMetaObject
            print "__call__", meta
        except:
            print "error for __call__"

        instance = cls.__new__(cls)
        return instance


class Klass(QtCore.QObject):
    __metaclass__ = MetaKlass



klass = Klass()
print klass
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120329/1d5d8089/attachment.html>


More information about the PyQt mailing list