{"id":80234,"date":"2021-01-13T09:30:10","date_gmt":"2021-01-13T04:00:10","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=80234"},"modified":"2026-06-03T15:28:27","modified_gmt":"2026-06-03T09:58:27","slug":"python-alarm-clock","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/","title":{"rendered":"Create an Alarm Clock in Python with GUI"},"content":{"rendered":"<p>There is no other way to learn something than to implement it practically. So we are here with another interesting project on python.<\/p>\n<p>This time, you will learn how to create a simple alarm clock with python and Tkinter.<\/p>\n<p>Python alarm clock is a gui application, which can be used on a computer to set an alarm. Although it&#8217;s a simple project for beginners, but it&#8217;s interesting to implement various functionalities.<\/p>\n<h3>Prerequisites<\/h3>\n<p>The prerequisites are: basic concepts of Python and Tkinter<\/p>\n<p>To install the libraries, you can use pip installer from the cmd\/Terminal:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">pip install tkinter\r\n<\/pre>\n<h3>Download Python Alarm Clock Code<\/h3>\n<p>Before proceeding ahead, please download source code of python alarm clock: <a href=\"https:\/\/drive.google.com\/file\/d\/1zi4dATRgOv19TS5VB-XiWVkPNcmMtvhP\/view?usp=drive_link\"><strong>Python Alarm Clock Code<\/strong><\/a><\/p>\n<h3>Creating main.py<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">from time import strftime \r\nfrom tkinter import * \r\n\r\nimport time\r\nimport datetime\r\nfrom pygame import mixer\r\n \r\nroot = Tk() \r\nroot.title('TechVidvan Alarm-Clock') \r\n\r\ndef setalarm():\r\n    alarmtime=f\"{hrs.get()}:{mins.get()}:{secs.get()}\"\r\n    print(alarmtime)\r\n    if(alarmtime!=\"::\"):\r\n        alarmclock(alarmtime) \r\n\r\ndef alarmclock(alarmtime): \r\n    while True:\r\n        time.sleep(1)\r\n        time_now=datetime.datetime.now().strftime(\"%H:%M:%S\")\r\n        print(time_now)\r\n        if time_now==alarmtime:\r\n            Wakeup=Label(root, font = ('arial', 20, 'bold'),\r\n            text=\"Wake up!Wake up!Wake up\",bg=\"DodgerBlue2\",fg=\"white\").grid(row=6,columnspan=3)\r\n            print(\"wake up!\")\r\n            mixer.init()\r\n            mixer.music.load(r'C:\\Users\\BOSS\\Desktop\\MyPlaylist\\WakeUP.mp3')\r\n            mixer.music.play()\r\n            break\r\n\r\n\r\nhrs=StringVar()\r\nmins=StringVar()\r\nsecs=StringVar()\r\n\r\ngreet=Label(root, font = ('arial', 20, 'bold'),\r\ntext=\"Take a short nap!\").grid(row=1,columnspan=3)\r\n\r\nhrbtn=Entry(root,textvariable=hrs,width=5,font =('arial', 20, 'bold'))\r\nhrbtn.grid(row=2,column=1)\r\n\r\nminbtn=Entry(root,textvariable=mins,\r\nwidth=5,font = ('arial', 20, 'bold')).grid(row=2,column=2)\r\n\r\nsecbtn=Entry(root,textvariable=secs,\r\nwidth=5,font = ('arial', 20, 'bold')).grid(row=2,column=3)\r\n\r\nsetbtn=Button(root,text=\"set alarm\",command=setalarm,bg=\"DodgerBlue2\",\r\nfg=\"white\",font = ('arial', 20, 'bold')).grid(row=4,columnspan=3)\r\n\r\ntimeleft = Label(root,font=('arial', 20, 'bold')) \r\ntimeleft.grid()\r\n  \r\nmainloop() \r\n<\/pre>\n<h4>Functions Used<\/h4>\n<p><strong>1. Setalarm:<\/strong> It sets an alarm by calling alarmClock method by passing the alarm time as argument(if the user has entered a correct and non-empty time).<\/p>\n<p><strong>2. alarmclock:<\/strong> This is the most important method because it performs the following tasks:<\/p>\n<p>a. It stores the current time in time_now in specified format (&#8220;%H:%M:%S&#8221;)<\/p>\n<p>b. It also checks if current time matches the alarm time. As soon as time matches it displays a wake-up message and plays the alarm song using pygame and mixer. And if doesn\u2019t match the time_now it continues step b after sleeping for one second.<\/p>\n<h4>Variables Used:<\/h4>\n<p>1. root: the main GUI window.<\/p>\n<p>2. Hrs, Mins, Secs: They are tkinter string variables that store the hour\u2019s, minute\u2019s and second\u2019s value entered by the user before setting an alarm.<\/p>\n<p>3. Greet: It is a label to display the message\u201d Take a short nap!\u201d.<\/p>\n<p>4. We also have hrbtn, minbtn , secbtn to take respective values from the user.<\/p>\n<h3>Python Alarm Clock Project Output<\/h3>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/01\/alarm-clock-output.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-80237\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/01\/alarm-clock-output.png\" alt=\"alarm clock output\" width=\"1318\" height=\"729\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>We have successfully created alarm clock project in python. This is an interesting python project for beginners where we used tkinter and pygame.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is no other way to learn something than to implement it practically. So we are here with another interesting project on python. This time, you will learn how to create a simple alarm&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":80238,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[3375,3376,483,3249],"class_list":["post-80234","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-alarm-clock","tag-python-alarm-clock","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 an Alarm Clock in Python with GUI - TechVidvan<\/title>\n<meta name=\"description\" content=\"Python Alarm Clock - Python project for beginners. Learn how to create an alarm clock in python with tkinter and pygame\" \/>\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\/python-alarm-clock\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create an Alarm Clock in Python with GUI - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Python Alarm Clock - Python project for beginners. Learn how to create an alarm clock in python with tkinter and pygame\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/\" \/>\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=\"2021-01-13T04:00:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-03T09:58:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-alarm-clock.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=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create an Alarm Clock in Python with GUI - TechVidvan","description":"Python Alarm Clock - Python project for beginners. Learn how to create an alarm clock in python with tkinter and pygame","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\/python-alarm-clock\/","og_locale":"en_US","og_type":"article","og_title":"Create an Alarm Clock in Python with GUI - TechVidvan","og_description":"Python Alarm Clock - Python project for beginners. Learn how to create an alarm clock in python with tkinter and pygame","og_url":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2021-01-13T04:00:10+00:00","article_modified_time":"2026-06-03T09:58:27+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-alarm-clock.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":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Create an Alarm Clock in Python with GUI","datePublished":"2021-01-13T04:00:10+00:00","dateModified":"2026-06-03T09:58:27+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/"},"wordCount":319,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-alarm-clock.jpg","keywords":["alarm clock","python alarm clock","Python project","python project for beginners"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/","url":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/","name":"Create an Alarm Clock in Python with GUI - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-alarm-clock.jpg","datePublished":"2021-01-13T04:00:10+00:00","dateModified":"2026-06-03T09:58:27+00:00","description":"Python Alarm Clock - Python project for beginners. Learn how to create an alarm clock in python with tkinter and pygame","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-alarm-clock.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2021\/01\/python-alarm-clock.jpg","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/python-alarm-clock\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Create an Alarm Clock in Python with GUI"}]},{"@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\/80234","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=80234"}],"version-history":[{"count":2,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80234\/revisions"}],"predecessor-version":[{"id":448082,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/80234\/revisions\/448082"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/80238"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=80234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=80234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=80234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}