python使用tkinter實(shí)現(xiàn)屏幕中間倒計時
本文實(shí)例為大家分享了python實(shí)現(xiàn)屏幕中間倒計時的具體代碼,供大家參考,具體內(nèi)容如下
先看下效果圖:
代碼:
import timefrom tkinter import Tk,Labelclass TimeShow():#實(shí)現(xiàn)倒計時 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()
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. ASP將數(shù)字轉(zhuǎn)中文數(shù)字(大寫金額)的函數(shù)2. ASP基礎(chǔ)入門第四篇(腳本變量、函數(shù)、過程和條件語句)3. jscript與vbscript 操作XML元素屬性的代碼4. XML在語音合成中的應(yīng)用5. JSP開發(fā)之hibernate之單向多對一關(guān)聯(lián)的實(shí)例6. 基于PHP做個圖片防盜鏈7. php使用正則驗(yàn)證密碼字段的復(fù)雜強(qiáng)度原理詳細(xì)講解 原創(chuàng)8. jsp 實(shí)現(xiàn)的簡易mvc模式示例9. PHP session反序列化漏洞超詳細(xì)講解10. HTML5實(shí)戰(zhàn)與剖析之觸摸事件(touchstart、touchmove和touchend)
