altis at semi-retired.com
Thu Jan 2 19:36:55 CET 2003
"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
> 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.
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>
More information about the Python-list