import tkinter as tk
import timea = 0
t1 = time.time()
def like():global aa += 1t2 = time.time()asd['text'] = '手速:%.4f 次/秒' % (a/(t2-t1))timelabel['text'] = '时间:%.2f 秒'% (t2-t1)like_point['text'] = '%d 次'% adef new():global aglobal t1a = 0t1 = time.time()asd['text'] = '手速:0次/秒'timelabel['text'] = '时间:0秒'like_point['text'] = '0次'
qwe = tk.Tk()
qwe.title('hello world')
qwe.geometry('600x600')
asd = tk.Label(qwe,text='like',fg='#FFFFFF',bg='#000000',font=(None, 40),width=20,height=1,
)
asd.pack()
timelabel = tk.Label(qwe,text='时间:0',fg='#FFFFFF', bg='#0000FF', font=('黑体',30),width=20,height=1,
)
timelabel.pack()
like_point = tk.Label(qwe,text='0次',fg='#00AA00', bg='#0000FF', font=('黑体',30),width=20,height=1,
)
like_point.pack()
btn = tk.Button(qwe,text="点赞",fg='#FFFFFF',bg='#0000FF',font=(None, 20),width=10,height=2,command=like,
)
btn.pack()
restart = tk.Button(qwe,text="重新开始",fg='#FFFFFF',bg='#0000FF',font=(None, 20),width=10,height=2,command=new,
)
restart.pack()
qwe.mainloop()