[PyQt] Proposal for New-style Signals
Phil Thompson
phil at riverbankcomputing.com
Thu Jan 24 13:40:47 GMT 2008
On Thursday 24 January 2008, David Boddie wrote:
> On Thu Jan 24 10:34:37 GMT 2008, Phil Thompson wrote:
> > On Thursday 24 January 2008, David Boddie wrote:
> > > I still can't see the attraction of this syntax. I sort of see the
> > > point of things like
> > >
> > > button.clicked.emit()
> > >
> > > but the stage 2 connect syntax looks inside-out.
> >
> > Because it's focused on the sender rather than the receiver? Your
> > suggestion below does as well.
>
> It's more perverse than that: it's focused on the signal itself. With the
> classic syntax
>
> self.connect(button, SIGNAL("clicked()"), self.doSomething)
>
> there's a nice pattern to follow:
>
> connect <sender> <signal> <receiver> <slot>
>
> even when <receiver> and <slot> are combined. Ideally, you could combine
> the <sender> and <signal>, but arguments complicate the issue. From a C++
> user's perspective, the self is redundant, but that's the case in lots of
> places in Python.
>
> With the signal-centric syntax, I think the meaning is different:
>
> btn.clicked.connect(self.on_clicked)
>
> The signal is saying, "Connect me to this slot."
Yes, although <sender>, <signal>, <receiver> and <slot> are still in the same
order.
> Not that there's anything wrong with that - it's just a different focus.
Yes, but your suggestion (which I like)...
btn.connect("clicked()", self.on_clicked)
...has the same issue.
Phil
More information about the PyQt
mailing list