主页 > 知识库 > python使用tkinter实现屏幕中间倒计时

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

热门标签:宾馆能在百度地图标注吗 南京crm外呼系统排名 郑州智能外呼系统中心 电销机器人 金伦通信 汕头电商外呼系统供应商 北京外呼电销机器人招商 云南地图标注 400电话 申请 条件 crm电销机器人

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

先看下效果图:

代码:

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()

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
  • python基于tkinter制作下班倒计时工具
  • python实现简单倒计时功能
  • python 实现倒计时功能(gui界面)
  • python实现七段数码管和倒计时效果
  • python实现倒计时小工具
  • python实现的简单窗口倒计时界面实例
  • python实现倒计时的示例
  • 基于python写个国庆假期倒计时程序

标签:梅州 文山 浙江 西宁 锡林郭勒盟 昆明 怀化 石家庄

巨人网络通讯声明:本文标题《python使用tkinter实现屏幕中间倒计时》,本文关键词  python,使用,tkinter,实现,屏幕,;如发现本文内容存在版权问题,烦请提供相关信息告之我们,我们将及时沟通与处理。本站内容系统采集于网络,涉及言论、版权与本站无关。
  • 相关文章
  • 下面列出与本文章《python使用tkinter实现屏幕中间倒计时》相关的同类信息!
  • 本页收集关于python使用tkinter实现屏幕中间倒计时的相关信息资讯供网民参考!
  • 推荐文章