python使用tkinter實(shí)現(xiàn)屏幕中間倒計(jì)時(shí)
本文實(shí)例為大家分享了python實(shí)現(xiàn)屏幕中間倒計(jì)時(shí)的具體代碼,供大家參考,具體內(nèi)容如下
先看下效果圖:
代碼:
import timefrom tkinter import Tk,Labelclass TimeShow():#實(shí)現(xiàn)倒計(jì)時(shí) 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=’倒計(jì)時(shí){}秒’.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’]= ’倒計(jì)時(shí){}秒’.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()
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Python2.6版本pip安裝步驟解析2. python中Ansible模塊的Playbook的具體使用3. python公司內(nèi)項(xiàng)目對(duì)接釘釘審批流程的實(shí)現(xiàn)4. Python 利用flask搭建一個(gè)共享服務(wù)器的步驟5. Python importlib模塊重載使用方法詳解6. 基于python實(shí)現(xiàn)matlab filter函數(shù)過(guò)程詳解7. Python中Anaconda3 安裝gdal庫(kù)的方法8. python用zip壓縮與解壓縮9. Python自動(dòng)化之定位方法大殺器xpath10. Python本地及虛擬解釋器配置過(guò)程解析
