【发布时间】:2015-01-18 22:58:37
【问题描述】:
所以我有一个带有两个简单选项的 Tkinter GUI,一个开始和停止按钮。我已经定义了 GUI 布局:
from Tkinter import *
def scanning():
while True:
print "hello"
root = Tk()
root.title("Title")
root.geometry("500x500")
app = Frame(root)
app.grid()
这里的开始按钮运行无限循环扫描,而停止按钮应该在按下时中断:
start = Button(app, text="Start Scan",command=scanning)
stop = Button(app, text="Stop",command="break")
start.grid()
stop.grid()
但是,当我点击开始按钮时,它总是被按下(假设是因为无限循环)。但是,我无法单击停止按钮来跳出 while 循环。
【问题讨论】:
标签: python user-interface tkinter