ziheng -学习测手速

# 1.窗口
import tkinter as tk
import time
window = tk.Tk()
window.geometry("300x400")
window.title("测手速游戏")

dian_zan_ci_shu  = 0
t2 = time.time()

def zan():
    global dian_zan_ci_shu
    dian_zan_ci_shu = dian_zan_ci_shu  + 1
    t3 = time.time()
    shi_jian_cha = t3-t2
    la["text"] = "giao:%d 次" % dian_zan_ci_shu
    t1["text"] = "时间:%.2f 秒" % shi_jian_cha
    shou_su["text"] = "手速:%.2f 次/秒"% (dian_zan_ci_shu/shi_jian_cha)

# 2.在窗口写一个文字 Label
la = tk.Label(window, text="点赞人数")
la.pack()
# 时间文字标签
t1 = tk.Label(window, text="时间")
t1.pack()
# 手速文字标签
shou_su = tk.Label(window, text="手速")
shou_su.pack()

# 3.在窗口写一个按钮 Button
btn = tk.Button(window, text="点赞", command=zan)
btn.pack()

# 循环
window.mainloop()
发布了516 篇原创文章 · 获赞 21 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/houlaos/article/details/105111330