python使用tkinter实现屏幕中间倒计时
本文实例为大家分享了python实现屏幕中间倒计时的具体代码,供大家参考,具体内容如下
先看下效果图:

代码:
import timefrom tkinter import Tk,Labelclass 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()
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持好吧啦网。
相关文章:
1. PHP生成带有雪花背景的验证码2. CentOS 8.1下搭建LEMP(Linux+Nginx+MySQL+PHP)环境(教程详解)3. Java Swing权威指南:Spinner Model Controls4. vue设置默认首页的操作5. SpringBoot可视化接口开发工具magic-api的简单使用教程6. JAVA教程:解析Java的多线程机制(6)7. Android刮刮乐效果-proterDuffXfermode的示例代码8. 基于JDBC访问MySql公共方法实例解析9. Java BigDecimal使用及基本运算(推荐)10. python 统计list中各个元素出现的次数的几种方法

网公网安备