{"id":14066,"date":"2020-09-11T17:13:54","date_gmt":"2020-09-11T17:13:54","guid":{"rendered":"https:\/\/holypython.com\/?p=14066"},"modified":"2021-06-17T16:42:55","modified_gmt":"2021-06-17T16:42:55","slug":"5-ways-to-create-an-alarm-in-python","status":"publish","type":"post","link":"https:\/\/holypython.com\/5-ways-to-create-an-alarm-in-python\/","title":{"rendered":"5 Ways to Create an Alarm in Python"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"14066\" class=\"elementor elementor-14066\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-9f14053 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"9f14053\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-a24a825\" data-id=\"a24a825\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-inner-section elementor-element elementor-element-e1696aa elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"e1696aa\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-ae04785\" data-id=\"ae04785\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-88923fe elementor-widget elementor-widget-text-editor\" data-id=\"88923fe\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Creating your alarm in Python can be anything between fun, educating, useful and even liberating.<\/p><p>For example, Windows alarm application is pretty but sometimes it&#8217;s too tedious to adjust each parameter with the mouse and you may wish to just type the values (date, hour, minute, second, millisecond etc.).<\/p><p>With Python you can create an alarm that works exactly the way you intend it to do and it can be a great learning project as well.<\/p><p>So, we have prepared numerous different methods that can count as an alarm and hopefully you will find some of them cool.<\/p><p>Featured image credit: <a href=\"https:\/\/www.laurachouette.com\" target=\"_blank\" rel=\"noopener\">Laura Chouette<\/a><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8106f20 elementor-widget elementor-widget-text-editor\" data-id=\"8106f20\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Holy Python is reader-supported. When you buy through links on our site, we may earn an affiliate commission.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b400939 elementor-widget__width-auto elementor-widget elementor-widget-heading\" data-id=\"b400939\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Creating Creative Alarms (<i>w\/ Python<\/i>)<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c0602af elementor-widget elementor-widget-text-editor\" data-id=\"c0602af\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>These ideas will construct the core programming of a Python alarm application. A combination of:<\/p><ul><li><a href=\"https:\/\/holypython.com\/how-to-schedule-tasks-with-py-files-python-manual-automated\/\" target=\"_blank\" rel=\"noopener\">Task Scheduling with Python method<\/a><\/li><li>Plus one of the Python alarm methods mentioned here<\/li><\/ul><p>will give you an OS level DIY alarm. If you won&#8217;t turn off your system or if you don&#8217;t mind leaving the alarm script or your programming IDE running in the background you can avoid using the Task Scheduler extension. In that case your alarm will probably be set for shorter time periods such as a few minutes to hours.<\/p><p>Here are 5 Alarm Ideas using Python and some of its default libraries!<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t<div class=\"elementor-column elementor-col-50 elementor-inner-column elementor-element elementor-element-578e264\" data-id=\"578e264\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-861d767 elementor-widget elementor-widget-html\" data-id=\"861d767\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<a href=\"https:\/\/datacamp.pxf.io\/c\/2872712\/1091988\/13294\" target=\"_top\" id=\"1091988\"><img fetchpriority=\"high\" decoding=\"async\" src=\"\/\/a.impactradius-go.com\/display-ad\/13294-1091988\" border=\"0\" alt=\"\" width=\"300\" height=\"600\"\/><\/a><img decoding=\"async\" height=\"0\" width=\"0\" src=\"https:\/\/imp.pxf.io\/i\/2872712\/1091988\/13294\" style=\"position:absolute;visibility:hidden;\" border=\"0\" \/>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7fb0476 elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"7fb0476\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon elementor-animation-pulse-grow\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"far fa-clock\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tEstimated Time\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\t5 mins\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-075bfe5 elementor-widget elementor-widget-raven-divider\" data-id=\"075bfe5\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-954acbd elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"954acbd\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon elementor-animation-pulse-grow\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"far fa-thumbs-up\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tSkill Level\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\tBeginner\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8715ca2 elementor-widget elementor-widget-raven-divider\" data-id=\"8715ca2\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-25e3766 elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"25e3766\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon elementor-animation-pulse-grow\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"far fa-bookmark\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tFunctions\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\t.sleep, .open, <br>.Beep, .system\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b94b463 elementor-widget elementor-widget-raven-divider\" data-id=\"b94b463\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-6b1ecbe elementor-position-left elementor-view-default elementor-mobile-position-top elementor-vertical-align-top elementor-widget elementor-widget-icon-box\" data-id=\"6b1ecbe\" data-element_type=\"widget\" data-widget_type=\"icon-box.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"elementor-icon-box-wrapper\">\n\n\t\t\t\t\t\t<div class=\"elementor-icon-box-icon\">\n\t\t\t\t<span  class=\"elementor-icon elementor-animation-pulse-grow\">\n\t\t\t\t<i aria-hidden=\"true\" class=\"fas fa-book\"><\/i>\t\t\t\t<\/span>\n\t\t\t<\/div>\n\t\t\t\n\t\t\t\t\t\t<div class=\"elementor-icon-box-content\">\n\n\t\t\t\t\t\t\t\t\t<h4 class=\"elementor-icon-box-title\">\n\t\t\t\t\t\t<span  >\n\t\t\t\t\t\t\tLibraries\t\t\t\t\t\t<\/span>\n\t\t\t\t\t<\/h4>\n\t\t\t\t\n\t\t\t\t\t\t\t\t\t<p class=\"elementor-icon-box-description\">\n\t\t\t\t\t\ttime, webbrowser,<br>win32api, win32com<br>os, random\t\t\t\t\t<\/p>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\t\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7a4e595 elementor-widget elementor-widget-raven-divider\" data-id=\"7a4e595\" data-element_type=\"widget\" data-widget_type=\"raven-divider.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<div class=\"raven-widget-wrapper\">\r\n\t\t\t<div class=\"raven-divider\">\r\n\t\t\t\t<span class=\"raven-divider-line raven-divider-solid\"><\/span>\r\n\t\t\t<\/div>\r\n\t\t<\/div>\r\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-b2db8a8 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"b2db8a8\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-ff98627\" data-id=\"ff98627\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-18106cc elementor-widget elementor-widget-heading\" data-id=\"18106cc\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">1- Using Webbrowser Library to Create a Python Alarm<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d62b106 elementor-widget elementor-widget-text-editor\" data-id=\"d62b106\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>Let&#8217;s start with the web browser method. You can easily open any page on your default web browser using <b>webbrowser<\/b> library.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-50991fb elementor-widget elementor-widget-html\" data-id=\"50991fb\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>import webbrowser\r\n\r\nwebbrowser.open(\"https:\/\/www.youtube.com\/watch?v=x0mmajhLKh8\")\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5064725 elementor-widget elementor-widget-text-editor\" data-id=\"5064725\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>So, just find a video you&#8217;d like to set as an alarm. It can be your favorite music or something inspirational on Youtube or another streaming\/video site.<\/p><p>Maybe check out &#8220;<a href=\"https:\/\/www.youtube.com\/watch?v=x0mmajhLKh8\" target=\"_blank\" rel=\"noopener\">New Day Video Clip<\/a>&#8221; from 50 Cent, Alicia Keys and Dr. Dre for ideas.<\/p><p>Alternatively you can set the link to\u00a0<\/p><ul><li>your favorite movie clips,\u00a0<\/li><li>upcoming movie trailers,\u00a0<\/li><li>your favorite Youtube Vlogger,\u00a0<\/li><li>nature sounds (ocean, forest, wind, rain etc.)<\/li><li>bird sounds<\/li><li>cute animals<\/li><li>puppy videos\u00a0<\/li><li>funny videos etc.<\/li><\/ul><div>So, the video depends on your preference, the event and the environment. You might choose different setups for an event like waking up, reminder of an event or reminder for taking a break.<\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-bb8e55f elementor-widget elementor-widget-image\" data-id=\"bb8e55f\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"1100\" height=\"733\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/FEhT8m2PGHk-Custom.jpg\" class=\"attachment-full size-full wp-image-14112\" alt=\"\" srcset=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/FEhT8m2PGHk-Custom.jpg 1100w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/FEhT8m2PGHk-Custom-300x200.jpg 300w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/FEhT8m2PGHk-Custom-1024x682.jpg 1024w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/FEhT8m2PGHk-Custom-768x512.jpg 768w\" sizes=\"(max-width: 1100px) 100vw, 1100px\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">If our methods are the minimalist end of an alarm spectrum, this must be the other end. Very cool nevertheless.<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-be0e64a elementor-widget elementor-widget-heading\" data-id=\"be0e64a\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">2- Python Alarm Using Print Function<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5e541c6 elementor-widget elementor-widget-text-editor\" data-id=\"5e541c6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>This one is my absolute favorite. Its beauty is its simplicity.<\/p><p>Apparently if try to print <b>&#8220;\\a&#8221;<\/b>, this triggers a Windows notification sound (I think it&#8217;s called warning sound. Whatever its called its a sound we&#8217;ve all heard thanks to Windows Operating System and it&#8217;s somewhat <u>alarm<\/u>ing indeed. <img decoding=\"async\" class=\"emoji\" role=\"img\" draggable=\"false\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.0.1\/svg\/1f609.svg\" alt=\"\ud83d\ude09\" \/>)<br \/>So all you have to do is to execute this code: <code>print (\"\\a\")<\/code><\/p><p>For a more sophisticated code you&#8217;d wanna put it in a loop or it will be too short to act as an alarm. But once in a loop it actually works surprisingly well. Very elegant and creative in my opinion.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b12f4fa elementor-widget elementor-widget-html\" data-id=\"b12f4fa\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>import time\r\n\r\nfor i in range(5):\r\n    time.sleep(1)\r\n    print(\"\\a\")\r\n    \r\n    \r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-710a07c elementor-widget elementor-widget-text-editor\" data-id=\"710a07c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"font-family: Merriweather;\"><span style=\"font-family: Merriweather, sans-serif;\">Also, we&#8217;re using Python&#8217;s convenient time library to create a little bit of delay between each chime.<\/span><\/p><p style=\"font-family: Merriweather;\"><b>This will create 5 Windows sounds with approximately 1 second breaks. Feel free to adjust\u00a0 for loop parameters according to your taste and heaviness of your snooze maybe.<\/b><\/p><p>You can also create a nested loop to produce multiple blocks of these with a longer break in between. Check out this code:<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-af4c53c elementor-widget elementor-widget-html\" data-id=\"af4c53c\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>import time\r\n\r\nfor i in range(10):\r\n    for i in range(4):\r\n        time.sleep(0.5)\r\n        print(\"\\a\")\r\n    time.sleep(3)\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-86d7ddf elementor-widget elementor-widget-text-editor\" data-id=\"86d7ddf\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>It will produce 10 blocks of alarm tunes which will consist of 4 chimes. Between blocks there will be a 3 second break. I don&#8217;t know if it&#8217;s just me but it&#8217;s mind blowing to me to be able to create something like this from print function and a couple of Python loops. Well, there is also the time library but I think you know what I mean.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4f8ae85 elementor-widget elementor-widget-heading\" data-id=\"4f8ae85\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">3- Win32api's Beep Method for a Proper Frequency Implementation<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-82b8a9f elementor-widget elementor-widget-text-editor\" data-id=\"82b8a9f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"font-family: Merriweather;\">Now, this is also simply a beep but it&#8217;s a more proper and complete method than the print method. Using win32api library you can actually make a precision on the frequency of the sound and adjust its length to the milisecond.<\/p><p style=\"font-family: Merriweather;\">This opens the door for lots of sound creativity. Check out this alarm tune creation method which will produce unique sequence of sound every time it&#8217;s run because of the implementation of <b>random<\/b> library&#8217;s <b>randint<\/b> method:<\/p><p style=\"font-family: Merriweather;\">Note: Frequency range is limited to approximately something like <b>37 to 32000.<\/b><\/p><p style=\"font-family: Merriweather;\"><b>Lower frequencies will create a very deep sound while high frequencies produce high pitch sounds.<\/b><\/p><p style=\"font-family: Merriweather;\"><b>Also, random library&#8217;s ranint simply produces a random integer between the values its given.<\/b><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-4ea3f6b elementor-widget elementor-widget-html\" data-id=\"4ea3f6b\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t    <pre rel=\"Python\"><code>import win32api\r\n    import random\r\n    \r\n    for i in range(5):\r\n        win32api.Beep(random.randint(37,10000), random.randint(750,3000))\r\n\r\n\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8e0c4b3 elementor-widget elementor-widget-image\" data-id=\"8e0c4b3\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t<figure class=\"wp-caption\">\n\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"733\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/BkJyueJRBeo-Custom.jpg\" class=\"attachment-full size-full wp-image-14113\" alt=\"\" srcset=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/BkJyueJRBeo-Custom.jpg 1100w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/BkJyueJRBeo-Custom-300x200.jpg 300w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/BkJyueJRBeo-Custom-1024x682.jpg 1024w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/BkJyueJRBeo-Custom-768x512.jpg 768w\" sizes=\"(max-width: 1100px) 100vw, 1100px\" \/>\t\t\t\t\t\t\t\t\t\t\t<figcaption class=\"widget-image-caption wp-caption-text\">Image credit: Vincent Chan<\/figcaption>\n\t\t\t\t\t\t\t\t\t\t<\/figure>\n\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c066fc6 elementor-widget elementor-widget-text-editor\" data-id=\"c066fc6\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"font-family: Merriweather;\"><b>Increasing frequency and decreasing length is another approach to creating an alarm in Python using Beep method. If this paranoia evoking &#8211; bunker style alarm won&#8217;t wake you up I don&#8217;t know what will. But hey, no one said it was gonna be a pleasant alarm. If you&#8217;re in the market for a pleasant alarm check out the next idea! \ud83d\ude42<\/b><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8ca2942 elementor-widget elementor-widget-html\" data-id=\"8ca2942\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>x=37\r\ny=2500\r\nfor i in range(13):\r\n    win32api.Beep(x,y)\r\n    x+=100\r\n    y-=120\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b959697 elementor-widget elementor-widget-heading\" data-id=\"b959697\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">4- Playing a Local Audio File Using Python<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-dfd0c3c elementor-widget elementor-widget-text-editor\" data-id=\"dfd0c3c\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"font-family: Merriweather;\">This might be the most appropriate approach if you&#8217;re particular about using an exact sound, chime, tune, song, audio book, speech, podcast or any other audio file for your self-made alarm. In my opinion bird chirping, ocean waves or funny audios make excellent alarm tunes.<\/p><p style=\"font-family: Merriweather;\">It can also be helpful in cases where you are missing an internet connection temporarily such as on a boat or off-grid cabin.\u00a0Playing a local audio is really easy with Python:<\/p><ul><li style=\"font-family: Merriweather;\">All you have to do is import <b>os<\/b> library and make use of its <b>.system<\/b> method.<\/li><\/ul><div><span style=\"font-family: Merriweather;\">Check out the example:<\/span><\/div>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d994143 elementor-widget elementor-widget-html\" data-id=\"d994143\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>import os\r\nf=\"birds_chirping.mp3\"\r\nos.system(f)\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-67a7409 elementor-widget elementor-widget-text-editor\" data-id=\"67a7409\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"font-family: Merriweather;\">If you use a path just make sure to use double backslashes instead of regular slashes. If it still doesn&#8217;t work try changing the direction of the slash. There can be conflicts due to operating system&#8217;s directory notation. This is usually the case for Windows to recognize the path.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d0fc7d3 elementor-widget elementor-widget-image\" data-id=\"d0fc7d3\" data-element_type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"1100\" height=\"733\" src=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/tvydY1W0-Custom.jpg\" class=\"attachment-full size-full wp-image-14114\" alt=\"\" srcset=\"https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/tvydY1W0-Custom.jpg 1100w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/tvydY1W0-Custom-300x200.jpg 300w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/tvydY1W0-Custom-1024x682.jpg 1024w, https:\/\/holypython.com\/wp-content\/uploads\/2020\/09\/tvydY1W0-Custom-768x512.jpg 768w\" sizes=\"(max-width: 1100px) 100vw, 1100px\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e73ca09 elementor-widget elementor-widget-text-editor\" data-id=\"e73ca09\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p>You can also use\u00a0<b>os.system<\/b>\u00a0method to open any other file such as video clips or movies.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3958743 elementor-widget elementor-widget-heading\" data-id=\"3958743\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">5- Win32com.client for Python Alarm with Video Files<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-1bf8516 elementor-widget elementor-widget-text-editor\" data-id=\"1bf8516\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"font-family: Merriweather;\">You can also use the Run method from <b>win32com.client<\/b> to run any file in your system locally. You can also use this method as an alternative to <b>webbrowser<\/b> because if you pass a web link as an argument to Windows Run it will automatically Run it in your default browser.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-2924e59 elementor-widget elementor-widget-html\" data-id=\"2924e59\" data-element_type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<pre rel=\"Python\"><code>import win32com.client\r\n\r\nshell = win32com.client.Dispatch(\"WScript.Shell\")\r\nshell.Run(\"Matrix_IV.mp4\")\r\n<\/code><\/pre>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-37fbc81 elementor-widget elementor-widget-heading\" data-id=\"37fbc81\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<h3 class=\"elementor-heading-title elementor-size-default\">Bonus: - Python Alarm Library on Pypi<\/h3>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-133681f elementor-widget elementor-widget-text-editor\" data-id=\"133681f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"font-family: Merriweather;\">If you&#8217;re still not satisfied with none of these methods or if you don&#8217;t want to deal with the Task Scheduling part (which is a fantastic method to improve your coding skill-set and practice Python) you can also check out this interesting alarm library created for Python\u00a0<a style=\"background-color: #ffffff;\" href=\"https:\/\/pypi.org\/project\/alarm\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-24c4dd2 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"24c4dd2\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-2af2fb4\" data-id=\"2af2fb4\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-f715fe3 elementor-widget elementor-widget-text-editor\" data-id=\"f715fe3\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t\t\t<p style=\"font-family: Merriweather;\"><span style=\"color: var( --e-global-color-text );\"><b>That&#8217;s all the methods we have. Thanks for reading! I hope you found some of these methods useful and entertaining. Using Python for personal solutions is a great way to immerse yourself in coding and engage with Python learning at a more conscious level.<\/b><\/span><\/p><p style=\"font-family: Merriweather;\">Please also consider sharing this article with your audience, followers, friends and family so they can also learn or hear a few simple but cool programming tricks.<\/p><p style=\"font-family: Merriweather;\">And also, you can check out <a href=\"https:\/\/holypython.com\/category\/tutorials\/scripting\/\">some other cool Python scripting ideas from HolyPython<\/a>.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>Creating your alarm in Python can be anything between fun, educating, useful and even liberating. For example, Windows alarm application is pretty but sometimes it&#8217;s too tedious to adjust each parameter with the mouse and you may wish to just type the values (date, hour, minute, second, millisecond etc.). With Python you can create an [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":19848,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[33,52,61],"tags":[],"class_list":["post-14066","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-beginner","category-tutorials","category-scripting"],"acf":[],"_links":{"self":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/posts\/14066","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/comments?post=14066"}],"version-history":[{"count":0,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/posts\/14066\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/media\/19848"}],"wp:attachment":[{"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/media?parent=14066"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/categories?post=14066"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/holypython.com\/wp-json\/wp\/v2\/tags?post=14066"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}