[PyQt] Type information for signals

Phil Thompson phil at riverbankcomputing.com
Wed Apr 25 08:40:06 BST 2012


On Sun, 22 Apr 2012 08:54:44 +0100, Andrew Suffield
<asuffield at suffields.me.uk> wrote:
> I'd rather like to be able to write code like this:
> 
> for name in dir(obj):
>   a = getattr(obj, name)
>   if isinstance(a, QtCore.pyqtSignal):
>     setattr(self, name, a)
> 
> Unfortunately, signals of objects are of class pyqtBoundSignal and I
> can't find a class object to pass to isinstance - does it exist?

No, easy to add.

> For similar purposes of metaclass hackery, it would be useful to get
> the string form out of a signal object so that I can call functions
> like QObject.connectNotify and QObject.receivers

So a __signal__ attribute to pyqtBoundSignal?

Should the value of the attribute already have the SIGNAL() macro applied
to it?

Phil


More information about the PyQt mailing list