python使用tkinter实现屏幕中间倒计时
本文实例为大家分享了python实现屏幕中间倒计时的具体代码,供大家参考,具体内容如下
先看下效果图:
代码:
importtime
fromtkinterimportTk,Label
classTimeShow():#实现倒计时
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)
defshow(self):
whileself.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()
defstart(self):
print('ok')
self.timeShowWin.mainloop()
if__name__=='__main__':
a=TimeShow(10)
a.start()
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持毛票票。
声明:本文内容来源于网络,版权归原作者所有,内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:czq8825#qq.com(发邮件时,请将#更换为@)进行举报,并提供相关证据,一经查实,本站将立刻删除涉嫌侵权内容。
热门推荐
8 小托班祝福语简短
10 带马的祝福语简短
11 海南考试祝福语结婚简短
12 简短宝贝祝福语大全集
13 心媳妇生日祝福语简短
14 给老公祝福语简短2026
15 感恩跨年祝福语大全简短
16 新年儿童祝福语大全 简短
17 小朋友上学祝福语简短
18 医师考试祝福语毕业简短