At 08:55 PM 11/26/2006, you wrote: >On 27/11/06, Dick Moores <[EMAIL PROTECTED]> wrote: >>I have a question about the "EXIT" button's command, >>command=sys.exit. It fails to quit the program when I've entered too >>large an integer for factoring, or for prime testing, and I don't >>want to wait any more for the result. When I'm running the program >>from my Win XP console, I can quit with a simple Ctrl+C, but this >>won't be available to the friend I may send the executable to. Is it >>possible to build in a way to smoothly interrupt, say, a factoring >>process that's taking too long? > >Well, as you may know, the "core" of Tkinter (or most GUIs, I think) >is the event loop. The event loop basically does this: >1. Look for events (mouse clicks, keypresses, etc.) >2. Process events (update widgets, call callbacks) >3. GOTO 1. > >So, in this specific case, the event loop is doing this: > >1. Look for events ==> user clicks on "factorise" button. >2. Process events ==> call "factorise" button callback. >3. Callback runs... >4. ...callback completes. >5. Look for events ==> user clicks on "exit" button. >6. Process events ==> call "exit" button callback. >7. Python exits. > >So, you can see why clicking your exit button won't interrupt the >calculation in progress. The only way you can do that is if you can >get the event loop to start looking for events again before the >callback finishes. And that means THREADS.
Thanks, John. I know nothing about threading. I see that Chun's _Core Python Programming_, 2nd ed. has a 30-page chapter on it. A good place to start? Dick _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor