我的计数器不会停止。当我第二次启动时,我希望它继续计数,而不是重新启动。Tkinter程序的行为不像我认为的那样
from tkinter import *
master = Tk()
Counter_Activation_Variable=3
def start():
Counts=0
Counter_Activation_Variable=0
button.configure(text = "Stop", command=stop)
while Counter_Activation_Variable == 0:
Counts = Counts+1
Textbox.delete(1.0, END)
Textbox.insert(END,(Counts))
master.update()
def stop():
Counter_Activation_Variable=5
button.configure(text = "Start", command=start)
master.update()
button = Button(master, text="Start",command=start, bg="grey")
button.pack(side='bottom', fill='none', expand=False, padx=4, pady=4)
master.title("Stopwatch")
Textbox = Text(master, height=1, width=175)
Textbox.pack(side='top', fill='none', expand=False, padx=4, pady=4)
master.mainloop()
描述性变量和方法名称真的会在这种情况下有所帮助:) –
你是什么意思对不起,如果它明显,但即时通讯新编码大部分这个我只是从其他网站一起凝结和理解 – PLP123
我可以弄清楚你的代码函数,但使用诸如“timer_status”而不是“a”或“seconds”而不是“x”的描述性变量名称,确实使编程变得光荣。这是一个很好的提示,因为你是新的:) –