Detect events positively

Xiao-Qin Xia xx758 at
Fri Jun 7 11:52:52 EDT 2002


The following code display two button:

from Tkinter import *
def Calculate(event = None):
        while 1:
def Exit(event = None):
        import sys
root = Tk()
btn_cal = Button(root, text="calculate", command = Calculate)
btn_exit = Button(root, text="exit", command = Exit)

if clicked the "calculate" button, the program will fall in a loop that 
will never end. So program will not response to clicking to the "exit" 
button, so it cannot be terminated normally. If we don't use multithread, 
can we add some code in the loop of the function Calculate to let it exit 
the loop after the user clicks the "exit" button or press a "Esc" key?

Many thanks from, 
Xiao-Qin Xia

More information about the Python-list mailing list