The application below has two buttons, 'count' and 'stop'.
When the 'stop' button is selected after 'count', it does not execute until the count command finishes at 500. Instead, it is desired to stop counting immediately and execute the 'stop' method.
Is there a simple way to handle this situation?
I notice Application() objects have a asyncevents(onoff) method in the Macintosh Library Module, but I am a PC, Windows user.
from Tkinter import *
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.grid()
self.createWidgets()
def __init__(self, master=None):
Frame.__init__(self, master)
self.grid()
self.createWidgets()
def createWidgets(self):
self.stop = Button(self,text='Emergency Stop!',command=self.stop)
self.count = Button(self,text='Count',command=self.count)
self.stop = Button(self,text='Emergency Stop!',command=self.stop)
self.count = Button(self,text='Count',command=self.count)
self.count.grid(row=0,column=0)
self.stop. grid(row=0,column=1)
self.stop. grid(row=0,column=1)
def count(self):
for i in range(501):
print i
for i in range(501):
print i
def stop(self):
print 'stop'
print 'stop'
app = Application()
app.mainloop()
app.mainloop()
-- http://mail.python.org/mailman/listinfo/python-list