如果从根窗口调用函数并且该函数没有解决方案或用户想要停止该函数,可以从根窗口完成吗?如果可以,怎么做?以下代码生成两个按钮 - 使用 start() 开始“同时”开始,但退出不能停止 start()。在 start() 中使用 root.update_idletasks() 不会产生任何效果。
#!/usr/bin/env python
from Tkinter import *
def start():
while True:
print "Stop me if you can from Quit"
root.update_idletasks()
root = Tk()
root.title('Example')
button1 = Button(root,text = 'Start', command = start)
button1.grid(row = 0, column = 0)
button2 = Button(root,text = 'Quit', command = root.destroy)
button2.grid(row = 1, column = 0)
root.mainloop()