[PyQt] simpler 'connect' function

Mark Summerfield mark at qtrac.eu
Thu Jan 17 10:46:42 GMT 2008


On 2008-01-17, Ewald de Wit wrote:
> On Wednesday 16 January 2008 09:21:40 Aaron Digulla wrote:
> > As for making the API simpler, I'd opt for
> >
> >      button.connectClicked(self.buttonWasClicked)
>
> Wouldn't it be nicer if the signals where attributes of your object,
> so that you could write
>
> 	button.clicked.connect(self.onButtonClicked)
>
> (and likewise for disconnect).

That seems like a nice syntax to me.

Qt Jambi (Qt bindings for Java) uses a similar (but not quite as nice)
syntax:

    button.clicked.connect(this, "buttonClicked()");

> This is basically what C# uses, although there the += and -=
> operators are used for connect and disconnect respectively.
> To connect one would get:
>
> 	button.clicked += self.onButtonClicked

I'm not at all keen on this though.

>
> I've adopted this notation in my Python programs because I think
> it's the most visually appealing.
>
> --
>   -- Ewald
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt



-- 
Mark Summerfield, Qtrac Ltd., www.qtrac.eu




More information about the PyQt mailing list