[PyQt] simpler 'connect' function
jbublitz at nwinternet.com
Wed Jan 16 08:39:33 GMT 2008
Just jumping in on the thread here,not replying to anyone in particular.
I modified (polite word for "hacked up") an example program written by Troy
Melhase for PyKDE3, and what he had done was kind of interesting, I thought:
sigClicked = SIGNAL ("clicked ()")
class MainWindow (KMainWindow):
def __init__ (self, parent):
self.connect (self.button, sigClicked, self.buttonClicked)
The program uses 15-20 signals, all defined and referenced as above.
It'd seem like it would be possible to have PyQt/PyKDE automatically do the
SIGNAL definitions (as predefined constants, for example SIG_CLICKED) and
then just reference them as in the connect statement above.
I don't know if any checking could be performed to validate that 'self.button'
really emits a 'sigClicked' or 'clicked ()' signal.
I also don't know if I'd really advocate this or if I'd do it this way again,
but it was a nice way to organize the program and still keeps things readable
- just thought I'd throw it out as one alternative.
More information about the PyQt