{"id":80012,"date":"2020-09-24T09:30:24","date_gmt":"2020-09-24T04:00:24","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=80012"},"modified":"2026-06-03T15:37:40","modified_gmt":"2026-06-03T10:07:40","slug":"countdown-clock-timer-python","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/","title":{"rendered":"Create Countdown Timer using Python"},"content":{"rendered":"<p><strong>Python Countdown Timer<\/strong> &#8211; Python project for beginners, is used to set a countdown timer. It displays how much time is left in your set time. It is like an alarm that will give the user options to set the time and when that time will over it will notify the user.<\/p>\n<h3>Countdown Clock &amp; Timer Python Project<\/h3>\n<p>The objective of this python project is to create a countdown timer and display time. In this python project, the user sets the time and by click on the start button, it starts the count from that time. When the time gets over ie when the countdown timer finishes it plays a sound.<\/p>\n<p>This project build with basic concept of python and libraries: Tkinter, time and playsound<\/p>\n<h2>Steps to Develop Python Countdown Timer<\/h2>\n<h3>Project Prerequisites<\/h3>\n<p><strong>Tkinter<\/strong> is a standard GUI Python library from which we can build GUI applications in the fastest and easiest ways.<\/p>\n<p>The<strong> playsound<\/strong> module is used when we want to play audio files with a single line of code. This doesn&#8217;t have any dependencies.<\/p>\n<p>The <strong>Python time module<\/strong> provides ways to represent time.<\/p>\n<p>To install the library, please run pip install command in prompt:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">pip install tkinter                                                                                                                                                                                     \r\npip install time\r\npip install playsound\r\n<\/pre>\n<h3>Download Countdown Timer Python Code<\/h3>\n<p>Please download source code of Countdown Timer Project: <a href=\"https:\/\/drive.google.com\/file\/d\/1v77BrYlLtWJ2AYBkl9ZswBJ_fG9h80-3\/view?usp=drive_link\"><strong>Python Countdown Timer<\/strong><\/a><\/p>\n<p>These are the steps to builds Countdown Clock And Timer Python project :<\/p>\n<ul>\n<li>Import required Modules<\/li>\n<li>Create a display window<\/li>\n<li>Display current time<\/li>\n<li>Create a countdown timer<\/li>\n<li>Create a button<\/li>\n<\/ul>\n<h4>1. Importing Required Module<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">from tkinter import *\r\nimport time\r\nfrom playsound import playsound\r\n<\/pre>\n<p>The first step in the program is to import libraries. Here, we required three modules so we need to import tkinter, time and <a href=\"https:\/\/pypi.org\/project\/playsound\/\">playsound<\/a> modules.<\/p>\n<h4>2. Create a Display Window<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">root = Tk()\r\nroot.geometry('400x300')\r\nroot.resizable(0,0)\r\nroot.config(bg ='blanched almond')\r\nroot.title('TechVidvan - Countdown Clock And Timer')\r\nLabel(root, text = 'Countdown Clock and Timer' , font = 'arial 20 bold',  bg ='papaya whip').pack()\r\n<\/pre>\n<ul>\n<li><strong>Tk()<\/strong> initializes tkinter to create the window<\/li>\n<li><strong>geometry()<\/strong> set the width and height of the window<\/li>\n<li><strong>resizable(0,0)<\/strong> prohibit users to resize the window<\/li>\n<li><strong>title()<\/strong> used to set the title of display window<\/li>\n<li><strong>bg<\/strong> used to set the color of background<\/li>\n<li><strong>Label()<\/strong> widget used to display one or more than one line of text that users can\u2019t modify<\/li>\n<li><strong>root<\/strong> is the name of our window<\/li>\n<li><strong>text<\/strong> which we display on the label<\/li>\n<li><strong>font<\/strong> in which the text is written<\/li>\n<li><strong>pack<\/strong> organizes widget in block<\/li>\n<\/ul>\n<h4>3. Create Current Time<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Label(root, font ='arial 15 bold', text = 'current time :', bg = 'papaya whip').place(x = 40 ,y = 70)\r\n\r\ndef clock():\r\n    clock_time = time.strftime('%H:%M:%S %p')\r\n    curr_time.config(text = clock_time)\r\n    curr_time.after(1000,clock)\r\n\r\ncurr_time =Label(root, font ='arial 15 bold', text = '', fg = 'gray25' ,bg ='papaya whip')\r\ncurr_time.place(x = 190 , y = 70)\r\nclock()\r\n<\/pre>\n<ul>\n<li><strong>strftime()<\/strong> method return the string representing the time in given format<\/li>\n<li><strong>after()<\/strong> method used to give a delay of 1000 millisecond which is 1 sec<\/li>\n<\/ul>\n<h4>4. Create Function to Start Timer<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">sec = StringVar()\r\nEntry(root, textvariable = sec, width = 2, font = 'arial 12').place(x=250, y=155)\r\nsec.set('00')\r\n\r\nmins= StringVar()\r\nEntry(root, textvariable = mins, width =2, font = 'arial 12').place(x=225, y=155)\r\nmins.set('00')\r\n\r\nhrs= StringVar()\r\nEntry(root, textvariable = hrs, width =2, font = 'arial 12').place(x=200, y=155)\r\nhrs.set('00\u2019)\r\n<\/pre>\n<ul>\n<li><strong>sec<\/strong> is a string type variable that stores the seconds.<\/li>\n<li><strong>mins<\/strong> is a string type variable that stores the minutes.<\/li>\n<li><strong>hrs<\/strong> is a string type variable that stores the hours<\/li>\n<\/ul>\n<p><strong>Entry()<\/strong> widget is used to create an input text field.<\/p>\n<ul>\n<li><strong>textvariable<\/strong> used to retrieve text from specific variable to entry widget<\/li>\n<li><strong>place()<\/strong> widgets place widgets in a specific position in the parent widget.<\/li>\n<\/ul>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">def countdown():\r\n    times = int(hrs.get())*3600+ int(mins.get())*60 + int(sec.get())\r\n    while times &gt; -1:\r\n        minute,second = (times \/\/ 60 , times % 60)\r\n        \r\n        hour = 0\r\n        if minute &gt; 60:\r\n            hour , minute = (minute \/\/ 60 , minute % 60)\r\n      \r\n        sec.set(second)\r\n        mins.set(minute)\r\n        hrs.set(hour)\r\n   \r\n        root.update()\r\n        time.sleep(1)\r\n\r\n        if(times == 0):\r\n            playsound('Loud_Alarm_Clock_Buzzer.mp3')\r\n            sec.set('00')\r\n            mins.set('00')\r\n            hrs.set('00')\r\n        times -= 1\r\n<\/pre>\n<ul>\n<li>times variable gets the hours value multiplied by 3600 (1 h = 3600 sec), mins value multiplied by 60 (1 min = 60 sec), and sec value.<\/li>\n<li>\u2018\/\/\u2019 operator returns the result of the division in a whole integer value<\/li>\n<li>\u2018%\u2019 operator used to returns the remainder of the division<\/li>\n<li>While time is greater then -1 the countdown will run. When times value become 0 then the countdown stop and a sound play that indicate your time is up.<\/li>\n<\/ul>\n<h4>5. Create Button<\/h4>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">Label(root, font ='arial 15 bold', text = 'set the time',   bg ='papaya whip').place(x = 40 ,y = 150)\r\n\r\nButton(root, text='START', bd ='5', command = countdown, bg = 'antique white', font = 'arial 10 bold').place(x=150, y=210)\r\n \r\nroot.mainloop()\r\n<\/pre>\n<p><strong>Button()<\/strong> widget used to display a button on window<\/p>\n<ul>\n<li>bd sets the size of the border<\/li>\n<li>command calls the function when we click on button<\/li>\n<\/ul>\n<p><strong>root.mainloop()<\/strong> is a method which executes when we want to run our program<\/p>\n<h3>Python Countdown Timer Project Output<\/h3>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/09\/python-countdown-timer-project-output.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80015\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/09\/python-countdown-timer-project-output.png\" alt=\"python countdown timer project output\" width=\"1366\" height=\"705\" \/><\/a><\/p>\n<h2>Summary<\/h2>\n<p>With this project in Python, we have successfully created the countdown clock and timer python project. We used the python tkinter library for graphics, time library to display current time, and playsound library to play sound. We learned how to display the current time and how to build a countdown timer.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python Countdown Timer &#8211; Python project for beginners, is used to set a countdown timer. It displays how much time is left in your set time. It is like an alarm that will give&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":80016,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[3272,3273,483,3249],"class_list":["post-80012","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-countdown-clock-timer","tag-python-countdown-timer","tag-python-project","tag-python-project-for-beginners"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Create Countdown Timer using Python - TechVidvan<\/title>\n<meta name=\"description\" content=\"Python Countdown Timer Project - Create a countdown clock timer and display time with the help of Tkinter, time and playsound libraries.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create Countdown Timer using Python - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Python Countdown Timer Project - Create a countdown clock timer and display time with the help of Tkinter, time and playsound libraries.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-09-24T04:00:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-03T10:07:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/python-countdown-timer.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create Countdown Timer using Python - TechVidvan","description":"Python Countdown Timer Project - Create a countdown clock timer and display time with the help of Tkinter, time and playsound libraries.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/","og_locale":"en_US","og_type":"article","og_title":"Create Countdown Timer using Python - TechVidvan","og_description":"Python Countdown Timer Project - Create a countdown clock timer and display time with the help of Tkinter, time and playsound libraries.","og_url":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-09-24T04:00:24+00:00","article_modified_time":"2026-06-03T10:07:40+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/python-countdown-timer.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Create Countdown Timer using Python","datePublished":"2020-09-24T04:00:24+00:00","dateModified":"2026-06-03T10:07:40+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/"},"wordCount":623,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/python-countdown-timer.jpg","keywords":["countdown clock &amp; timer","python countdown timer","Python project","python project for beginners"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/","url":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/","name":"Create Countdown Timer using Python - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/python-countdown-timer.jpg","datePublished":"2020-09-24T04:00:24+00:00","dateModified":"2026-06-03T10:07:40+00:00","description":"Python Countdown Timer Project - Create a countdown clock timer and display time with the help of Tkinter, time and playsound libraries.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/python-countdown-timer.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/09\/python-countdown-timer.jpg","width":1200,"height":628,"caption":"python countdown timer"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/countdown-clock-timer-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Create Countdown Timer using Python"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=80012"}],"version-history":[{"count":1,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80012\/revisions"}],"predecessor-version":[{"id":448098,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80012\/revisions\/448098"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/80016"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=80012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=80012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=80012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}