python 實(shí)現(xiàn)倒計(jì)時(shí)功能(gui界面)
運(yùn)行效果:
完整源碼:
##import library from tkinter import * import time from playsound import playsound ## display window root = Tk() root.geometry('400x300') root.resizable(0,0) root.config(bg ='blanched almond') root.title('TechVidvan - Countdown Clock And Timer') Label(root, text = 'Countdown Clock and Timer' , font = 'arial 20 bold', bg ='papaya whip').pack() #display current time####################### Label(root, font ='arial 15 bold', text = 'current time :', bg = 'papaya whip').place(x = 40 ,y = 70) ####fun to display current time def clock(): clock_time = time.strftime('%H:%M:%S %p') curr_time.config(text = clock_time) curr_time.after(1000,clock) curr_time =Label(root, font ='arial 15 bold', text = '', fg = 'gray25' ,bg ='papaya whip') curr_time.place(x = 190 , y = 70) clock() #######################timer countdown########## #storing seconds sec = StringVar() Entry(root, textvariable = sec, width = 2, font = 'arial 12').place(x=250, y=155) sec.set('00') #storing minutes mins= StringVar() Entry(root, textvariable = mins, width =2, font = 'arial 12').place(x=225, y=155) mins.set('00') # storing hours hrs= StringVar() Entry(root, textvariable = hrs, width =2, font = 'arial 12').place(x=200, y=155) hrs.set('00') ##########fun to start countdown def countdown(): times = int(hrs.get())*3600+ int(mins.get())*60 + int(sec.get()) while times > -1: minute,second = (times // 60 , times % 60) hour = 0 if minute > 60: hour , minute = (minute // 60 , minute % 60) sec.set(second) mins.set(minute) hrs.set(hour) root.update() time.sleep(1) if(times == 0): playsound('Loud_Alarm_Clock_Buzzer.mp3') sec.set('00') mins.set('00') hrs.set('00') times -= 1 Label(root, font ='arial 15 bold', text = 'set the time', bg ='papaya whip').place(x = 40 ,y = 150) Button(root, text='START', bd ='5', command = countdown, bg = 'antique white', font = 'arial 10 bold').place(x=150, y=210) root.mainloop()
想要獲得更多關(guān)于python的資訊、工具、實(shí)例,請(qǐng)關(guān)注python客棧
以上就是python 實(shí)現(xiàn)倒計(jì)時(shí)功能(gui界面)的詳細(xì)內(nèi)容,更多關(guān)于python 倒計(jì)時(shí)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
- python實(shí)現(xiàn)倒計(jì)時(shí)的示例
- python實(shí)現(xiàn)倒計(jì)時(shí)小工具
- python實(shí)現(xiàn)的簡(jiǎn)單窗口倒計(jì)時(shí)界面實(shí)例
- python實(shí)現(xiàn)簡(jiǎn)單倒計(jì)時(shí)功能
- python實(shí)現(xiàn)七段數(shù)碼管和倒計(jì)時(shí)效果
- python使用tkinter實(shí)現(xiàn)屏幕中間倒計(jì)時(shí)
- python實(shí)現(xiàn)windows倒計(jì)時(shí)鎖屏功能
- 親手教你用Python打造一款摸魚倒計(jì)時(shí)界面
- python基于tkinter制作下班倒計(jì)時(shí)工具
- 基于Python實(shí)現(xiàn)倒計(jì)時(shí)工具
相關(guān)文章
tensorflow學(xué)習(xí)教程之文本分類詳析
初學(xué)tensorflow,借鑒了很多別人的經(jīng)驗(yàn),參考博客對(duì)評(píng)論分類(感謝博主的一系列好文),本人也嘗試著實(shí)現(xiàn)了對(duì)文本數(shù)據(jù)的分類,下面這篇文章主要給大家介紹了關(guān)于tensorflow學(xué)習(xí)教程之文本分類的相關(guān)資料,需要的朋友可以參考下2018-08-08Pymysql實(shí)現(xiàn)往表中插入數(shù)據(jù)過程解析
這篇文章主要介紹了Pymysql實(shí)現(xiàn)往表中插入數(shù)據(jù)過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-06-06使用Python將字符串轉(zhuǎn)換為格式化的日期時(shí)間字符串
這篇文章主要介紹了使用Python將字符串轉(zhuǎn)換為格式化的日期時(shí)間字符串,需要的朋友可以參考下2019-09-09使用python telnetlib批量備份交換機(jī)配置的方法
今天小編就為大家分享一篇使用python telnetlib批量備份交換機(jī)配置的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-07-07Python實(shí)現(xiàn)服務(wù)端渲染SSR的示例代碼
服務(wù)端渲染是一種常見的技術(shù)策略,特別是在需要改善網(wǎng)站的搜索引擎優(yōu)化(SEO)和首屏加載時(shí)間的場(chǎng)景下,本文將介紹如何利用?Python?實(shí)現(xiàn)?SSR,感興趣的可以了解下2024-02-02PyQt5實(shí)現(xiàn)用戶登錄GUI界面及登錄后跳轉(zhuǎn)
PyQt5是強(qiáng)大的GUI工具之一,通過其可以實(shí)現(xiàn)優(yōu)秀的桌面應(yīng)用程序。本文主要介紹了PyQt5實(shí)現(xiàn)用戶登錄GUI界面及登錄后跳轉(zhuǎn),具有一定的參考價(jià)值,感興趣的可以了解一下2021-11-11Python檢查判斷一個(gè)數(shù)是不是另一個(gè)數(shù)的整數(shù)次冪實(shí)例深究
在數(shù)學(xué)和計(jì)算中,確定一個(gè)數(shù)是否為另一個(gè)數(shù)的整數(shù)次冪是一個(gè)常見而重要的問題,例如,我們可能需要判斷一個(gè)數(shù)是否是某個(gè)數(shù)的平方、立方或其他冪次,本文將探討在Python中如何實(shí)現(xiàn)這一功能,通過數(shù)學(xué)方法和算法檢查一個(gè)數(shù)是否是另一個(gè)數(shù)的整數(shù)次冪2023-12-12