<p>您的<code>Counter</code>函数在每次单击时调用<code>root.after(1000,Counter)</code>,并在单击时立即修改<code>Time</code>标签。当您足够快地单击按钮时,您可以安排多个<code>root.after</code>并将秒数相加。你知道吗</p>
<p>要修改当前脚本,可以跟踪当前操作,并调用<code>root.after_cancel</code>暂停操作。你知道吗</p>
<pre><code>from tkinter import *
PAUSE = False
HOUR, MINUTE, SECOND = 0, 0, 0
action = None #keep track on current action and also avoid click spam
def start():
'''Command for START button'''
global PAUSE, action
PAUSE = False
...
if not action:
Counter()
def pause():
'''Command for PAUSE button'''
global PAUSE, action
...
if action:
root.after_cancel(action)
action = None
def reset():
'''Command for RESET button'''
global HOUR, MINUTE, SECOND, PAUSE, action
...
HOUR, MINUTE, SECOND = 0, 0, 0
action = None
def Counter():
'''Updating hour, minute and seconds'''
global HOUR, MINUTE, SECOND, action
if PAUSE is False:
if SECOND == 59:
if MINUTE == SECOND == 59:
HOUR += 1
if MINUTE == 59:
MINUTE = 0
else:
MINUTE += 1
SECOND = -1
SECOND += 1
Time.config(text='{}:{}:{}'.format(str(HOUR).zfill(2), str(MINUTE).zfill(2), str(SECOND).zfill(2)))
action = root.after(1000, Counter)
root = Tk()
...
start_button = Button(root, text='START', font=("Arial", 16), fg='black', width=8, command=lambda: root.after(1000,start)) #to avoid the instant second increment
</code></pre>