【发布时间】:2013-07-26 20:40:27
【问题描述】:
所以我有这个按钮来启动东西,就像这样
self.buttontext = StringVar()
self.buttontext.set("Start")
self.button = Button(self.bottomframe, textvariable=self.buttontext, command=self.start)
当它启动时,我希望用户能够在需要时将其缩短,方法是在启动后立即将同一个按钮更改为停止按钮
def start(self):
self.button.config(command=self.stop)
self.buttontext.set("Stop")
permission = True
for ...
if update:
run properly
else:
end prematurely
self.button.config(command = self.start)
self.buttontext.set("Start")
在循环的每次迭代中都考虑一个布尔值。 stop 函数会将 update 更改为 false 以便循环
def stop(self):
permission = False
但是,在我单击“开始”后,我猜想控件不再在主循环中并且按钮没有响应,尽管按钮在运行时期间更改了其属性。我怎样才能使按钮响应,以便它可以被打断?
【问题讨论】: