[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] chain signals, disconnecting an "emit" slot
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2011-10-07 16:55:33
Message-ID: 7fe32ae0d1c4dff7eb4ab70b95d0dd45 () localhost
[Download RAW message or body]

On Fri, 07 Oct 2011 18:42:39 +0200, Pierre-Louis Bonicoli
<pierre-louis.bonicoli@gmx.fr> wrote:
> Hi,
> 
> I encounter a problem using "emit" method of a signal as a slot of
> another signal. Problem occurs using "disconnect".
> 
> Here is sample code, 'ok' and 'cancel' inherit from QAbstractButton:
> 
> ok.pressed.connect(cancel.pressed.emit)
> ok.pressed.disconnect(cancel.pressed.emit)
> 
> The second statement raise an exception:
> "TypeError: 'builtin_function_or_method' object is not connected"
> 
> Calling "disconnect" without parameter works fine.
> 
> If I use an intermediate function, TypeError is not raised:
> 
> def reemit():
>     cancel.pressed.emit()
> 
> ok.pressed.connect(reemit)
> ok.pressed.disconnect(reemit)
> 
> Behaviour is the same with old style signals.
> 
> Is there a way to not use an intermediate function ?
> 
> sip: 4.12.4
> PyQt: 4.8.3
> Qt: 4.7.3
> 
> Test cases in attachment.
> 
> Thanks,
> 
> Pierre-Louis

You can connect signals to signals...

ok.pressed.connect(cancel.pressed)

Phil
_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic