位置: IT常识 - 正文

❤️国庆假期快到了,用python写个倒计时程序,助你熬到假期!❤️

编辑:rootadmin
国庆假期快到了,想查查还有几天几小时到假期,这对程序员小菜一碟,轻轻松松用python写个倒计时程序(天、时、分、秒),助你熬到假期! 一、先看效果: 二、安装python: 1、下载安装python 下载安装python3.9.6,进入python官方网站://www.python.org/ 点击 ...

推荐整理分享❤️国庆假期快到了,用python写个倒计时程序,助你熬到假期!❤️,希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:,内容如对您有帮助,希望把文章链接给更多的朋友!

国庆假期快到了,想查查还有几天几小时到假期,这对程序员小菜一碟,轻轻松松用python写个倒计时程序(天、时、分、秒),助你熬到假期!

一、先看效果:

二、安装python:1、下载安装python

下载安装python3.9.6,进入python官方网站://www.python.org/

点击Python 3.9.6

❤️国庆假期快到了,用python写个倒计时程序,助你熬到假期!❤️

直接安装即可。

2、验证安装成功。

按win+R输入cmd,打开控制台,输入python -V,输出python版本号说明安装成功。

三、代码##import libraryfrom tkinter import *import timefrom datetime import datetime,timedelta################GUI to display window ##########################root = Tk()root.geometry('450x300')root.resizable(0,0)root.config(bg ='blanched almond')root.title('国庆倒计时')Label(root, text = '国庆倒计时' , font = 'arial 20 bold', bg ='papaya whip').pack()############GUI to display current time#######################Label(root, font ='arial 15 bold', text = ' 当前时间:', bg = 'papaya whip').place(x = 40 ,y = 70)#######################GUI to set the future time ##########Label(root, font ='arial 15 bold', text = ' 到达时间:', bg = 'papaya whip').place(x = 40 ,y = 110)#set yearyear_set = StringVar()Entry(root, textvariable =year_set , width = 4, font = 'arial 12').place(x=175, y=115)Label(root, font ='arial 15', text = '-', bg = 'papaya whip').place(x = 215 ,y = 110)year_set.set('0000')#set monthmonth_set= StringVar()Entry(root, textvariable =month_set, width =2, font = 'arial 12').place(x=235, y=115)Label(root, font ='arial 15', text ='-', bg = 'papaya whip').place(x = 260 ,y = 110)month_set.set('00')#set dayday_set= StringVar()Entry(root, textvariable =day_set, width =2, font = 'arial 12').place(x=275, y=115)day_set.set('00')# set hourhour_set= StringVar()Entry(root, textvariable =hour_set, width =2, font = 'arial 12').place(x=305, y=115)Label(root, font ='arial 15', text = ':', bg = 'papaya whip').place(x = 330 ,y = 110)hour_set.set('00')# set minmin_set= StringVar()Entry(root, textvariable =min_set, width =2, font = 'arial 12').place(x=345, y=115)Label(root, font ='arial 15', text = ':', bg = 'papaya whip').place(x = 370 ,y = 110)min_set.set('00')# set secsec_set= StringVar()Entry(root, textvariable =sec_set, width =2, font = 'arial 12').place(x=385, y=115)sec_set.set('00')#######################GUI to display timer countdown ##########Label(root, font ='arial 15 bold', text = ' 倒计时:', bg ='papaya whip').place(x = 40 ,y = 150)#storing secondssec = StringVar()Entry(root, textvariable = sec, width = 2, font = 'arial 12').place(x=325, y=155)Label(root, font ='arial 15', text = '秒', bg = 'papaya whip').place(x = 350 ,y = 150)sec.set('00')#storing minutesmins= StringVar()Entry(root, textvariable = mins, width =2, font = 'arial 12').place(x=275, y=155)Label(root, font ='arial 15', text = '分', bg = 'papaya whip').place(x = 300 ,y = 150)mins.set('00')# storing hourshrs= StringVar()Entry(root, textvariable = hrs, width =2, font = 'arial 12').place(x=225, y=155)Label(root, font ='arial 15', text = '时', bg = 'papaya whip').place(x = 250 ,y = 150)hrs.set('00')# storing daysdays= StringVar()Entry(root, textvariable = days, width =2, font = 'arial 12').place(x=175, y=155)Label(root, font ='arial 15', text = '天', bg = 'papaya whip').place(x = 200 ,y = 150)days.set('00')#########fun to display current time#############def clock(): clock_time = time.strftime('%Y-%m-%d %H:%M:%S %p') curr_time.config(text = clock_time) curr_time.after(1000,clock)curr_time =Label(root, font ='arial 15 bold', text = '', fg = 'gray25' ,bg ='papaya whip')curr_time.place(x = 175 , y = 70)clock()##########fun to start countdown########def countdown(): #now = datetime.now() #end = datetime((year_set).get(),(month_set).get(),(day_set).get(),(hour_set).get(),(min_set).get(),(sec_set).get(),00); global seconds_now now = time.time() lt_ = time.strptime(f'{(year_set).get()} {(month_set).get()} {(day_set).get()} {(hour_set).get()} {(min_set).get()} {(sec_set).get()}', '%Y %m %d %H %M %S') end = time.mktime(lt_) times=int (end-now) #.total_seconds()); while times > -1: minute,second = (times // 60 , times % 60) hour = 0 if minute > 60: hour , minute = (minute // 60 , minute % 60) day=0 if hour>24: day,hour=(hour//24,hour%24) sec.set(second) mins.set(minute) hrs.set(hour) days.set(day) root.update() time.sleep(1) times -= 1Button(root, text='START', bd ='5', command = countdown, bg = 'antique white', font = 'arial 10 bold').place(x=150, y=210) root.mainloop()四、运行

打开工程文件,在地址栏里输入cmd,按Enter回车,即打开控制台。

输入python main.py,按回车就打开了程序GUI界面。

到达时间填2022年10月1日,按start按钮,就开始放假倒计时啦!

本文链接地址:https://www.jiuchutong.com/zhishi/313307.html 转载请保留说明!

上一篇:phpcms评论模块出错怎么办(php用户评论)

下一篇:c语言野指针产生的原因(c语言指针妙用)

  • 小规模纳税人企业所得税计算
  • 股权转让需要缴纳企业所得税吗
  • 什么是应税所得率方式
  • 完税价格是含税价格吗?
  • 公司名称变更期间可以投标吗
  • 红字发票和蓝字一样吗
  • 固定资产投资损失怎么做账
  • 增值税负数申报监控
  • 通过物流中心再送货配货属视同销售吗
  • 无形资产日常维护支出会计处理
  • 企业政府性征地补偿款如何合法使用
  • 公司出售自用汽车如何开票
  • 个人所得税如何做会计分录
  • 怎么作废未使用的发票
  • 冲红的电子发票要怎么处理
  • 仓储行业税率是多少
  • 报完税后反结账调整主营业务收入可以吗?
  • 餐饮发票怎么进行财税处理?
  • 销售二手车需要注意什么
  • 外挂项目跨年结转分录怎么做?
  • 无法卸载系统更新 backup
  • 英雄联盟怎么改左键移动
  • 事业单位自筹什么意思
  • 行政事业单位的营业执照叫什么
  • 报销招待费的会计怎么做
  • 股东分红怎么处理
  • php判断链表是否有环
  • 以太网没有internet
  • 在建工程进项税额转出
  • php数组函数输出《咏雪》里有多少"片"字
  • 企业购进房产怎么抵扣
  • 土地投资入股是否缴纳土地增值税12366
  • 企业固定资产有哪些
  • window10怎么取消快捷方式
  • php imagecopymerge
  • PHP:imageantialias()的用法_GD库图像处理函数
  • 专家评审费发放新规定2023
  • 递延收益与递延所得税资产的区别
  • php分页思路
  • ue4ui界面制作
  • 什么叫python
  • 结存成本怎么计算先进先出法
  • 对方公司开收据盖什么章
  • 劳务派遣公司账务处理
  • mysqlbinlog -vvv
  • 善意取得增值税专用发票
  • 结转材料成本差异所需科目
  • 百旺税控盘会自动清卡吗
  • 生产企业出口退税申报流程操作
  • SQL server 2008安装程序遇到以下错误 sku
  • sqlserver233报错原因
  • MySQL中distinct语句的基本原理及其与group by的比较
  • 小规模纳税人水利基金税率
  • 善意取得增值税专用发票所得税
  • 工程预付款是否含规费和税金
  • 上期计提的费用怎么入账
  • 将自产产品用于管理部门 增值税
  • 制造费用月末怎么结转到生产成本
  • 酒店支付清洗费属于什么会计科目
  • 收到税务局汇算清缴退所得税怎么做账
  • 支付厂房租赁费现金流
  • 远程认证软件可以卸载吗
  • jdbc连接sqlserver数据库查询数据画饼图
  • mysql跨服务器查询语句
  • ssh访问windows
  • win8.0升级win8.1
  • 如何关闭windows8的密码
  • ubuntu怎样
  • win10 20h2 v2
  • win10系统更新出错怎么办
  • 协同编程工具
  • 如何用dos命令删除程序
  • java的gui框架
  • jquery返回顶部
  • android原生框架
  • 河北省网上税务局电子税务局
  • 进出口备案登记表是哪个部门发的
  • 四川区划调整公示最新
  • 用于直接销售消费品的消费税计入
  • 电力营销岗
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设