Skip to content

Latest commit

 

History

History

Level_5

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

readme.md

Scroll Down

PYTHON : 10 DAYS LEVEL-UP CHALLANGE [DAY-5]

5. KEEP YOUR EYES COOL !

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.

Require Topics :

so here we go...



Steps :



- Import Modules

First, we need to import Time Module and Plyer Module.

    from plyer import notification  
    import time

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



- Set Title & Message

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.'


- Set Notification

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  
        ) 

Note : For more information about notification.notify() Click here.

image



- Run as exe

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

run exe

  • 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)


Stop the exe

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 = False
  • or
    • Stop it from start --> task manager --> processes --> vs code --> python --> end task

start --> task manager Stop exe


task manager --> processes --> vs code --> python --> end task Stop exe



output

output


Code : Exercise 5


END

See You In Level 6 👀....