Congratulations!.. We're reached half of this challange.
On day 5 we will create Eye Health Notifier for pregrammers like us. In this program we create a notifier that will notify the programmer to take a break to rest the eyes. This notifier usually alerts to rest for 5 minutes, in every 1 hour.
so here we go...
Steps :
First, we need to import Time Module and Plyer Module.
from plyer import notification
import time- Here we only import a specific Python Class from whole Plyer Module.
Time Module : Provides many ways of representing time in code, such as objects, numbers, and string
Plyer Module : Provide Notification tool in python for desktop
We ser basic variables, named Title & Msg which include the string data to show in the notification.
Title = 'GREETINGS FROM YOUR HEALTH!'
Msg = 'Keep Your Eyes Cool & Calm, via 5 min Break. \nThank you for reading. Have a Good Day.'Now we set our notification with the help of notification.notify() method of notification class in plyer.
while(True):
time.sleep(60*60)
notification.notify(
title = Title,
message = Msg,
app_icon = None,
timeout = 10,
toast = False
) -
For continuous notifications, we use while loop with
infinite iteration. -
after that we set
Msg&Titlein notification.notify().
Note : For more information about
notification.notify()Click here.
Warning : For verifying that program has not any error, run this as normal python file Before Run this as an exe
We need to run this file as exe instead of normal python file.
- To run this file as exe in background run this command in terminal:
pythonw .\Level_5\exe5.py
- After run this file as an exe it run in the background without interrupt any other operation just like normal exe. and after 1 hour it will send notification and will continuously sending notification after gap of 1 hour.
Note : For Find the output immediate keep
time.sleep()for some minor second like.
time.sleep(10)
Once the exe file being run, it will continuously run repetedly in background.
To Stop It :- make while loop finite
i = True
while(i == True):
time.sleep(60*60)
notification.notify(
title = Title,
message = Msg,
app_icon = None,
timeout = 10,
toast = False
)
i = Falseor- Stop it from
start --> task manager --> processes --> vs code --> python --> end task
- Stop it from
task manager --> processes --> vs code --> python --> end task

Code : Exercise 5
See You In Level 6 👀....



