使用tkinter弄了一个很基础的计时器,不过没有按钮
from tkinter import *
counter = 0
def run_counter(digit): # digit是标签
def counting():
global counter
counter += 1
digit.config(text=str(counter)) # .config()的效果就是把括号里的内容加到标签
digit.after(1000, counting) # 在1000毫秒后执行counting()函数,即循环执行counting
counting()
root = Tk()
root.title('计时器')
digit = Label(root, bg='yellow', fg='blue', height=5, width=30, font='宋体 10 bold')
digit.pack()
run_counter(digit)
root.mainloop()