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

List:       pykde
Subject:    Re: [PyKDE] Binding parameters to slots
From:       "Phil Thompson" <phil () riverbankcomputing ! co ! uk>
Date:       2004-12-16 15:38:37
Message-ID: 40990.82.68.80.137.1103211517.squirrel () 82 ! 68 ! 80 ! 137
[Download RAW message or body]

> Hi -
>
> I'm trying to connect a signal in my class to a signal, but bind one of
> its parameters to the signalling object:
>
> For instance, I want to do something like
>
> self.connect( button, qt.SIGNAL('clicked()'),
>                lambda button=button: sys.stdout.write(button) )
>
> or
>
> self.connect( button, qt.SIGNAL('clicked()'),
>                lambda button=button, self=self: self.slotTest(button) )
>
> None of the options I've tried seem to work. Is this possible??

The problem is that connect() does not take a reference to the slot
object, and the lambda function is garbage collected as soon as connect()
returns.

Phil

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

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