<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: EjinJS</title>
    <description>The latest articles on DEV Community by EjinJS (@ejinjs).</description>
    <link>https://dev.to/ejinjs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F535317%2F15b05688-9823-4ca7-b404-e7ad483f5266.png</url>
      <title>DEV Community: EjinJS</title>
      <link>https://dev.to/ejinjs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ejinjs"/>
    <language>en</language>
    <item>
      <title>Make Simple Alarm in Python</title>
      <dc:creator>EjinJS</dc:creator>
      <pubDate>Tue, 08 Dec 2020 06:19:42 +0000</pubDate>
      <link>https://dev.to/ejinjs/make-simple-alarm-in-python-40c</link>
      <guid>https://dev.to/ejinjs/make-simple-alarm-in-python-40c</guid>
      <description>&lt;p&gt;This is a very simple post and i give you guys some more tips about libraries to expand your alarm application,if you have knowledge about any python GUI , You can easily convert this into a GUI application&lt;/p&gt;

&lt;p&gt;Always the first things will be installing requirements&lt;br&gt;
As i said this is a simple alarm so we choose simple libraries for this &lt;/p&gt;

&lt;p&gt;At,First install a Library called playsound , to play the sound &lt;br&gt;
the next thing is datetime module , which is built in python module,so there is no need to install it &lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Make a new python file , name the file any name you like!!&lt;br&gt;
Import the modules &lt;br&gt;
        from playsound import playsound&lt;br&gt;
        from datetime import datetime&lt;/p&gt;

&lt;p&gt;Make a function called alarm()&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YBEHyoAO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cmfy2j7scyc98o8m2ryw.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YBEHyoAO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cmfy2j7scyc98o8m2ryw.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;put current_state = False , which means now alarm is not ringing or the time to ring hasnt reached yet...&lt;/p&gt;

&lt;p&gt;make a varieable and set the time you want to ring , Note write the time in String , also remember datetime module is in 24hr Format &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tguPN_zz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/io81mbryt7pqu8r1v44w.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tguPN_zz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/io81mbryt7pqu8r1v44w.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now make a while loop Like this &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_-GFagto--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q13ac1ze1fwgj0f7doak.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_-GFagto--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/q13ac1ze1fwgj0f7doak.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;

&lt;p&gt;I explain what is happening here this loops works while the current state is at False , next we set a localtime , datetime.now() returns us current date and time , we strip the hour and minutes using strftime('%H:%M') &lt;br&gt;
Now we make an IF statement &lt;br&gt;
if the localtime is equal to the alarm time(which we set at the first) , it will print some text and with the playsound module it will play a music or something when the if statement is correct&lt;br&gt;
 &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9I_zUoIn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ry8rbepe7datibpqduhc.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9I_zUoIn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ry8rbepe7datibpqduhc.PNG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;type the path of that music in your computer as parameter for playsound function&lt;/p&gt;

&lt;p&gt;That's it hope you liked this post &lt;br&gt;
make sure to rate this post if alarm worked well&lt;br&gt;
feel free to comment in the post &lt;br&gt;
Have great day Little Programmers!!&lt;/p&gt;

</description>
      <category>python</category>
      <category>alarm</category>
    </item>
  </channel>
</rss>
