python使用tkinter实现屏幕中间倒计时

作者:酷酷的波波 时间:2021-03-10 22:28:11 

本文实例为大家分享了python实现屏幕中间倒计时的具体代码,供大家参考,具体内容如下

先看下效果图:

python使用tkinter实现屏幕中间倒计时

代码:


import time
from tkinter import Tk,Label

class TimeShow():#实现倒计时

def __init__(self,time_show=5):
   self.timeShowWin=Tk()
   self.timeShowWin.overrideredirect(True)
   self.timeShowWin.attributes('-alpha',1)
   self.timeShowWin.attributes('-topmost',True)
   self.timeShowWin.attributes('-transparentcolor','black')  
   self.time_show = time_show
   self.time_label=Label(self.timeShowWin,text='倒计时{}秒'.format(self.time_show),font=('楷体',25),fg='red',bg='black')
   self.time_label.pack(fill='x',anchor='center')
   self.timeShowWin.geometry('+'+str(int(self.timeShowWin.winfo_screenwidth()/2))+'+'+str(125))
   self.timeShowWin.after(1,self.show)

def show(self):
   while self.time_show >= 0:
     print('time_label={}'.format(self.time_label))
     self.time_label['text']= '倒计时{}秒'.format(self.time_show)
     self.timeShowWin.update()
     self.time_show -= 1
     time.sleep(1)
   self.timeShowWin.destroy()

def start(self):
   print('ok')
   self.timeShowWin.mainloop()

if __name__ == '__main__':
 a=TimeShow(10)
 a.start()

来源:https://blog.csdn.net/qq_39758896/article/details/114367700

标签:python,tkinter,倒计时
0
投稿

猜你喜欢

  • 利用python实现AR教程

    2021-07-09 16:39:04
  • GoFrame框架gcache的缓存控制淘汰策略实践示例

    2023-07-22 06:41:19
  • CSS Type set: 在线字体调整工具

    2008-03-02 15:36:00
  • ORACLE常见错误代码的分析与解决三

    2010-07-26 13:28:00
  • Django-celery-beat动态添加周期性任务实现过程解析

    2021-07-29 13:09:49
  • Python表达式的优先级详解

    2021-09-21 14:24:59
  • python pickle 和 shelve模块的用法

    2023-11-07 22:41:11
  • 解决python运行效率不高的问题

    2023-04-01 05:31:36
  • SQL截取字符串函数分享

    2011-11-03 17:07:37
  • Python semaphore evevt生产者消费者模型原理解析

    2021-11-14 12:52:39
  • 常见SQL Server 2000漏洞及其相关利用

    2007-10-01 14:45:00
  • CMS不要让MySQL为你流泪

    2008-12-11 14:38:00
  • 解决CentOS下ImportError: No module named '_sqlite3'的问题

    2022-03-14 20:13:57
  • VB应用程序访问SQL Server的常用方法

    2009-01-21 14:28:00
  • Python和C语言利用栈分别实现进制转换

    2022-10-02 15:43:15
  • Python大数据之使用lxml库解析html网页文件示例

    2022-05-10 11:06:53
  • 一文详解Python中的Map,Filter和Reduce函数

    2022-03-02 07:51:28
  • Python 给某个文件名添加时间戳的方法

    2023-02-10 21:12:56
  • Python反射和内置方法重写操作详解

    2023-07-06 12:00:02
  • 利用Python生成Excel炫酷图表

    2023-03-09 21:52:00
  • asp之家 网络编程 m.aspxhome.com