主頁 > 知識庫 > python使用tkinter實現(xiàn)屏幕中間倒計時

python使用tkinter實現(xiàn)屏幕中間倒計時

熱門標(biāo)簽:Win7旗艦版 百度AI接口 企業(yè)做大做強(qiáng) 硅谷的囚徒呼叫中心 呼叫中心市場需求 電話運(yùn)營中心 客戶服務(wù) 語音系統(tǒng)

本文實例為大家分享了python實現(xiàn)屏幕中間倒計時的具體代碼,供大家參考,具體內(nèi)容如下

先看下效果圖:

代碼:

import time
from tkinter import Tk,Label

class TimeShow():#實現(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í)有所幫助,也希望大家多多支持腳本之家。

您可能感興趣的文章:
  • python基于tkinter制作下班倒計時工具
  • python實現(xiàn)簡單倒計時功能
  • python 實現(xiàn)倒計時功能(gui界面)
  • python實現(xiàn)七段數(shù)碼管和倒計時效果
  • python實現(xiàn)倒計時小工具
  • python實現(xiàn)的簡單窗口倒計時界面實例
  • python實現(xiàn)倒計時的示例
  • 基于python寫個國慶假期倒計時程序

標(biāo)簽:海南 濟(jì)南 山西 長沙 山西 安康 崇左 喀什

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《python使用tkinter實現(xiàn)屏幕中間倒計時》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266