[Pygui] signals and slots

Mark Summerfield list at qtrac.plus.com
Tue Dec 1 09:52:12 CET 2009


On 2009-12-01, Greg Ewing wrote:
> inhahe wrote:
> > The reason I like signals and slots so much is that slots is that I
> > don't need always need to subclass - I can often create widgets and
> > have things respond to them just by making the object in one line and
> > then connecting it the next.
> 
> I find I hardly ever need to subclass widgets in PyGUI
> either, at least not controls.
> 
> Usually I *do* create a subclass of Window or Dialog to
> act as a container for my controls. I tend to do this
> even when it's not strictly necessary, as a convenient
> way of organising the code.
> 
> Having done that, it's very natural to give it a method
> that updates the state of the controls based on the
> prevailing conditions, and trigger it with action
> properties.

There is another way of maintaining state: use a state machine.
Qt 4.6 facilitates this (although I think only a few examples make use
of it yet). Nonetheless, I think it is interesting and given that it is
property-based might be an approach worth considering for a really
Pythonic GUI API:
http://doc.trolltech.com/4.6-snapshot/statemachine-api.html


-- 
Mark Summerfield, Qtrac Ltd, www.qtrac.eu
    C++, Python, Qt, PyQt - training and consultancy
        "Rapid GUI Programming with Python and Qt" - ISBN 0132354187


More information about the Pygui mailing list