Alarm clock using python tkinter | python project | #python #coding #programming

Akansha Yadav builds an alarm clock in Python using tkinter, datetime, and winsound. The app runs a background thread that checks the system time against a user-selected alarm time, then plays a .wav file when they match. You pick hours, minutes, and seconds from dropdown menus and hit Set Alarm to start monitoring.
Chapters
Let's create an alarm clock application using Python tkinter module. So this is going to be the output. We have 3 option menu, 1 button, and 2 text displays at the top. So I am importing the libraries which are required for this project. The first is going to be tkinter, then datetime, then time, then winsound, and then threading. Winsound is basically for the sound. Let's start by creating an object of tkinter, setting the geometry, and then following up with the threading. Module. So from thread module, I'm just targeting as an alarm, then creating an alarm function with an infinite loop where I'm going to set the alarm time, which is going to be the time which you are going to set using the option menu. We will create the option menu later on. Then waiting for 1 second, then setting the current time. Current time I'm going to take from the laptop screen. So for this purpose, I'm going to use the datetime module. So I'm using datetime.datetime.now, which is going to take the current time. Then printing the current time and the alarm time, then checking whether the set alarm is equal to the current time or not. If it is not, then it will continue. If it is, then it will print time to wake up and the sound will play up. You have to use any sound and you have to paste the sound inside the folder within which you are creating this Python file. Once you have the file, copy the link— copy the path of that particular sound and paste it instead of sound.wav. And then you can follow up by creating the labels, frames, buttons, and option menus. Once you have created all 3 things, you have to follow up with the option menu, multiple options. So in case of hours, you will create up to 24 because we do have 24 hours in a day. And then following up with the minutes, you will— we do have 60 minutes, so we will create 60 options for that. So in this case, make sure you are making it as a string variable root. All going to be an option menu. But before that, you have to set it as a string var, and then follow up with the next variable called min or mins. Just like in my case, I'm going to use minutes.set, and then mins is the variable in which I am creating option menu and passing all the minutes that I have created above as a string variable. Same way, I will do it for the seconds. We will go up to 60 as we have 60 minutes. Same we will use over here as well. String variable you will use, and make sure you are adding all these things onto the object that you have created above, that is root. Once you are done up to 60, you have to add it onto the option menu. Yeah, we will add it to the option menu onto the frame. Then wherever you wanted to pack it, left, right, or center, you will set it over there. Then creating a button because we do need a button of set alarm. Then executing the tkinter. So let's run the Python file. Once I run the Python file, here we got the output on the another screen. Well, yeah, this one is the output. These three are the options. So one is, let's suppose I'm setting the alarm time anytime, like as per the current time of my laptop. I just wanted to check it, so I'm just updating it with this. 39. Let's set it and then set alarm. So inside the terminal you will get the outputs like the current time and the set time. Current time is 15:38:51 and my set time is 39. So once it is the same, it will say time to wake up and it plays a sound as well. So if you like the video, don't forget to subscribe the channel.










