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

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

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

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

先看下效果圖:

代碼:

import time
from tkinter import Tk,Label

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

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

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

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

    • 400-1100-266