zoukankan      html  css  js  c++  java
  • 考试计时器练习

    Source file

    01 import tkinter
    02 import time
    03  
    04 star=time.time()
    05 
    06 def gettime(): 
    07     elap=time.time()-star# 获取时间差
    08     hours=int(elap/3600)
    09     minutes = int((elap-hours*3600)/60)
    10     seconds = int(elap-minutes*60.0-hours*3600)
    11     var.set('%02d:%02d:%02d' %(hours, minutes, seconds))
    12     root.after(1000, gettime)# 每隔1s调用函数自身获取时间
    13 
    14 root = tkinter.Tk()
    15 root.title('考试计时器')
    16 root.geometry('1000x400')
    17 var=tkinter.StringVar()
    18 tkinter.Label(root,text='考试计时',font='black 50 bold').pack(side='top');
    19 lb=tkinter.Label(root, textvariable=var, fg='red', font=("微软雅黑", 150))# 设置字体大小颜色
    20 lb.pack(side='top')
    21 #Quit按钮退出;Run按钮打印计算结果
    22 tkinter.Button(root, text='退出', command=root.quit).pack(side='left')
    23 tkinter.Button(root, text='运行', command=gettime).pack(side='right')
    24 root.mainloop()
    

    为更美好的明天而战!!!
  • 相关阅读:
    plusOne
    lengthOfLastWord
    maxSubArray
    countAndSay
    学生会管理系统-后端个人总结
    基于图结构实现地铁乘坐线路查询
    地铁线路项目简要分析
    Spring Boot 路由
    Spring Boot 项目配置的使用方法
    IDEA搭建Spring Boot项目
  • 原文地址:https://www.cnblogs.com/lovely-bones/p/11391338.html
Copyright © 2011-2022 走看看