Issues of state (was: Tkinter or wxpython?)

Hendrik van Rooyen mail at microcorp.co.za
Wed Aug 8 04:01:12 EDT 2007


"Paul Rubin" <http:/...nvalid> wrote:

> claird at lairds.us (Cameron Laird) writes:
> > >application in the web app model (I haven't even touched on the whole
> > >stateless HTTP being mapped to a stateful environment issue, or the
> > >need to manage the local web server) actually buys you anything. I
> > .
> > Go ahead:  touch on statefulness.  I've been pondering the topic
> > lately, and wonder what's new on the subject.  I find it plenty
> > difficult to cast this as anything but a big liability for the
> > Web app team.
> 
> I'm not sure what you're getting at in this context.  You can write a
> desktop app where the window system communicates with a gui toolkit
> through a socket (at least that's how X windows works), or you can
> write a web app where a browser communicates with an http listener
> through a socket.  What's the difference, as far as application state
> is concerned?  
> 
> I haven't used wxpython but for tkinter you'd typically have a gui
> event loop in its own thread, communicating with the application
> through queues.  Similarly you can use BaseHTTPServer to collect
> browser hits and get the data out of them with the cgi module
> functions before passing them to the app.  If you want to handle
> multiple concurrent users you get into the usual issues of web
> servers, but if you're just doing a single user web implementation as
> an alternative to a desktop gui, some rudimentary locking is probably
> enough to stop accidental simultaneous connections.
> 
> If the application is simple enough, you can just write it as a cgi
> and keep the state in disk files.

Something that is often overlooked is keeping some state in the buttons.
It involves changing the text, colour and the command binding, and 
possibly setting up a callback using .after for time outs, if necessary.
You can do quite complicated sequences like this, if you have a mind to.

Its a bit of a PITA - but then all state machines are, no matter how you
implement them.  Their chief advantage is that they force you to think
of all the possibilities.

- Hendrik

--
Enrol now in Heavy Henry's Wholesome Hackadamy,
for a course in single button GUI design.
The sacred crocodiles are for the moment leashed.





More information about the Python-list mailing list