[PyQt] Re: multiple signal connect

Ruben Fonseca rf at 7syntax.com
Wed Aug 20 23:39:01 BST 2008


On Wed, 2008-08-20 at 15:17 -0400, Daniel Miller wrote:
> Ahh, sorry, that will have the same problem you had before. Here's a  
> better version:

:-)

> def slotmaker(button):
>      def slot():
>          self.button_clicked(button)
>      button.__slot = slot
> 
> for button in [ ... ]:
>      QtCore.QObject.connect( ... , slotmaker(button))
> 
> 
> Note: it might not be possible to keep a reference to the slot on the  
> button itself--not sure if attribute assignment is possible directly  
> on qt objects that are not subclassed in Python. If not just keep a  
> list of slots attached to 'self' (your class) or something like that.

So all I am seeing is that these things of anonymous/lambda functions
are evil in Python, because of the lexical/binding thing...

Anyway, your other email seems to have a better way of solving this, and
it's now working great. So thank you for your help :-)

Ruben

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080820/d5adb52c/attachment.bin


More information about the PyQt mailing list