GUI-programming

Laura Creighton lac at strakt.com
Thu Jan 2 15:58:52 EST 2003


I hadn't thought of using generators like that.  Thank you.

Laura 

> 
> "Laura Creighton" <lac at strakt.com> wrote in message
> news:mailman.1041500703.16262.python-list at python.org...
> >
> > If you mean, 'while I am running my application, I want my users
> > to be able to interrupt things by clicking on buttons' then you need
> > to thread your application.  The best way to communicate between
> > threads is using a Queue object, and
> > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965
> > will show you how to do that.
> 
> Actually, I was pleasantly surprised to find that in many cases you can
> avoid threads and Queue by using a generator. I reworked the hopalong sample
> in PythonCard to take advantage of this.
> 
> http://pythoncard.sourceforge.net/samples/hopalong.html
> 
> A loop calls the generator function, the generator does a yield, the loop
> gives the GUI a chance to process an event like the user clicking on a
> Cancel button and then if the cancel button didn't set a flag like
> stopDrawing then the loop continues. In most cases I still use threads and
> Queue, but for this type of visualization a generator or simply yielding to
> the GUI event manager in a loop may be enough. Of course, tkinter might not
> have the same capabilities in that regard as wxPython <wink>
> 
> ka
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list





More information about the Python-list mailing list