Make A Bed Time Reminder Using Python | Tkinter | Windows Task Scheduler | Create Popup With Python

preview_player
Показать описание
This is a bedtime reminder window. it is built using Python and is scheduled using the Windows task scheduler. It pops up every 5 minutes at night and reminds us to go to bed.

let's start building it. let's create a file with an extension.PYW. Let's check if this works. now we can start writing the code. first, we will import the tkinter library and the time library. let's create a window of Tkinter. Now let's add a text inside the window, named label. It will have the test time to sleep. This does not get displayed until the label is packed.
Now the label is displayed. But the window name is displayed as tk.
let's change the label to bedtime reminder. Now let's change the position of the window, and shift it to be displayed at the bottom right corner of the screen. Now we are able to see the expected window with the required message. but if we click anywhere on another window then this window goes behind. We will add a window attribute to keep this window at the top. Now even if we click on another window this bedtime reminder window in remains on top. As we run the code a window with a sleeping reminder message is displayed, but this code runs indefinitely, it does not have a stop. To stop it we will have to close it manually by clicking on the close icon. To resolve this issue we will add a destroy statement which will close the window after 5000 mili seconds or 5 seconds. we can modify the time to make the window stay on the screen longer. now it is working and we are good to proceed with the next step of scheduling this task from the Windows task scheduler. Then it will pop up at the time specified and remind me to sleep.

Open Windows task scheduler. Click on Create task. In the General tab provide basic the task name and description. Go to the triggers tab and click on new. The trigger scheduled show is to run or start a task from the 1st of January 2024 at 10 pm, this task will start a program every 5 minutes for the next 1 hour, that means till 11 pm. Change the parameters as per your requirements. Now go to the Actions tab and click on new.
in action select Start a program. for the Program/script browse the path of the python .pyw file. Click okay and we are good to go.

Now as we just have to wait and watch, at the correct time the sleep reminder will appear automatically. It will be on top of all the other windows open. And it will remind us to go to bed. So go to bed on time and don't waste your time watching videos in incognito mode.

Python EveryDay !!!
Рекомендации по теме