[PyQt] Is the result of SIGNAL() a constant?

Aaron Digulla digulla at hepe.com
Wed Jan 9 09:41:37 GMT 2008

Quoting Phil Thompson <phil at riverbankcomputing.co.uk>:

>> From the documentation, I got the impression that the result of SIGNAL()
>> is more or less a constant. Is this code valid?
>>    signal = SIGNAL()
>>    self.connect(w1, signal, self.w1Clicked)
>>    self.connect(w2, signal, self.w2Clicked)
> Yes - given a correct call to SIGNAL().
>> ie. can I predefine all signals in my app, save them somewhere (to save
>> typos) and avoid the additional SIGNAL() calls? Or do I have to call
>> SIGNAL() every time?
> type(SIGNAL('')) would show that it is just a string.

That confuses me a bit because when I try to pass a string as the  
second argument to connect, I get "argument 2 has a wrong type" :)

But anyway: How much work would it be to have SIP generate constants  
for all SIGNAL's in a class? So I could say:

     self.connect(w1, w1.SOME_SIGNAL, ...)

Pro: Doesn't break old code, API, etc. No more typos (or python will  
warn about a missing attribute) and PyDev could offer auto-completion  
for signals, too!


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."

More information about the PyQt mailing list