[PyQt] simpler 'connect' function

Aaron Digulla digulla at hepe.com
Tue Jan 15 08:32:31 GMT 2008


Quoting Peter Shinners <pshinners at blizzard.com>:

>> No, but a few ideas have been thrown around on the list in the past
> couple
>> of days.
>>
>> Your suggestion is nice and concise - the dropping of SIGNAL() was
> briefly
>> discussed during developed of PyQt4.
>
> Allowing string arguments for the signal/slot name would be a good
> improvement. Hopefully the change can be made for connect and emit.
>
> I'd still vote for connect to be a method on QObject instances. Since
> the first argument to connect must always be a QObject instance (?), it
> would cut down on the awkwardness.

Sorry, I can't follow you here. 1) signal and slot already take string  
arguments. This discussion is to get rid of them. 2) connect is  
already a method of QObject. Since you have to connect two objects,  
you must always pass the second one as a parameter to the  
first.connect() call.

Currently, my favorite is:

     self.connect(other.CLICKED, ....)

because that avoids typos and folds the first and second argument of  
the connect call into one argument. I'm just curious how you can split  
"other.CLICKED" into "other" and "other.__class__.CLICKED" in connect  
without losing compatibility with old code.

     self.connectClicked(other, ...)

would be more simple but it's a brain twister: clicked doesn't belong  
to self but to other.

     other.connectClicked(self.otherWasClicked)

might be the way to go.

Regards,

-- 
Aaron "Optimizer" Digulla a.k.a. Philmann Dark
"It's not the universe that's limited, it's our imagination.
Follow me and I'll show you something beyond the limits."
http://www.pdark.de/



More information about the PyQt mailing list