0
我真的不知道通过在python中按下按钮来设置变量。例如:python tkinter按钮设置变量为false
done = False
...
range_button = Button(self.parent, text="start", command=lambda....
...
while done:
.....
但我真的不知道如何在python中做这样的事情,任何帮助?
我真的不知道通过在python中按下按钮来设置变量。例如:python tkinter按钮设置变量为false
done = False
...
range_button = Button(self.parent, text="start", command=lambda....
...
while done:
.....
但我真的不知道如何在python中做这样的事情,任何帮助?
对Tkinter做这件事没什么特别的 - 如果完成是一个全局变量(或一个实例变量),只需将其设置为任何你想要的值。重要的部分是,它必须是一个非局部变量。
range_button = Button(..., command=stop_loop)
def stop_root():
global done
done = True
def something_else():
global done
while !done:
...
严格地说,你不需要与循环功能的global done
声明,因为该功能是不会改变的变量的值。不过,我认为这会让你的代码更加明显。