Making A Drink Water Reminder Using Python

Hi there, today we will be talking about something very serious. We have seen most of the programmers are more concerned about their codes than their own health. As a result, we face some major health issues (for example:- Muscle Cramps, Constant Headache , decreased urine output, sleepness etc.) .” An healthy programmer is a happy programmer ” — the most effective way to keep ourselves healthy is to keep ourselves hydrated. In this article, we are going to create a ‘Drink Water’ Reminder or Notifier using Python which will remind us to drink water periodically. A few lines of code can be used to develop this notifier.

So ,let’s get started right away …

Drink Water Reminder Project

Requirements:  

Basic knowledge of python. We can use any ide ( for example:  https://code.visualstudio.com/download , https://jupyter.org/).

For better understanding, go through https://studygyaan.com/python/desktop-battery-percentage-notifier-using-python this first.

Modules:

1. Plyer : Plyer is a platform independent module in python, that helps us to access features of our hardware / platforms. 

2. Time : There is a popular time module available in Python which provides many ways of representing time in code, such as objects, numbers, and strings.

Installation:

Time module comes with python, so we don’t need to install it. On other hand, plyer is not a build in module. We have to install it .

Firstly, we have to open command prompt in administrator mode. Then, enter command  —

pip install plyer

Approach:

Step 1: First we have to import the time module, and from plyer we will import notification .

 from plyer import notification
 import time 

Step 2: Second we have to call the notify method of the class. In this case, the parameters of the method is Title (title of our notification), Message (required message of our notification) and timeout (reqrequired time for displaying the message or notification , we have set it to 10).

    notification.notify(
             title="......",
             message=".......",
             timeout=10
     ) 

Step 3: Finally,  we will add a sleep function to show the notification again after some time .

            time.sleep (60 * 60)

It means ,after every 60 minutes or one hour it will remind us or notify us to drink water.

Source Code:

import time
from plyer import notification
if __name__ == '__main__':
    while True:
        notification.notify(
            title = "**Please Drink Water Now!!",
            message ="Drinking Water Helps to Maintain the Balance of Body Fluids.",
            timeout= 10
            )
        time.sleep(60*60)

Output:

Drink Water Reminder

Benefits of this notifier:

Adult humans are 60 percent water, and our blood is 90 percent water. Having a lot of water in the body may reduce physical strain if heat stress occurs during work . Nowadays, we are too busy to remember having to drink water enough and regularly, but we don’t need to worry much, let ‘drink water’ remind us to drink water if we always forget it.