Creating a python script for a “do it yourself” reminder is very easy! The player library is all we need 🙂
First let's install the library:
pip install plyer
Before moving on to our reminder script, let's take a look at the notification module that will allow us to generate a notification.
The import of the notification module is done like this:
from plyer import notification
The function to use will be notification.notify, its main parameters are (full docs here):
title (str) - Title of the notification
message (str) - Message contained within the notification
app_name (str) - Name of the application
app_icon (str) - Icon to display next to the notification message
timeout (int) - Time to display the notification in seconds (default 10)
ticker (str) - Text to display in the notification bar
We are ready
Now that everything is configured and described, we are ready for our script.
The script below will display a notification with the title
“⏰ REMINDER” and the message “Have a break 🙂”.
The notification will appear for 5 seconds ( timeout=5 ) every 15 seconds ( time.sleep(15) ).
The notification will have as its icon the file “icon.ico” contained within the folder where we decide to save our script.
Please note: the “app_icon” parameter only accepts .ico type files
import time
import pathlib
from plyer import notification
curr_path = pathlib.Path(__file__).resolve().parent
notification_message= '''
Have a break 🙂
'''
if __name__ == "__main__" :
while ( True ):
notification.notify(
title= "⏰ REMINDER" ,
message=notification_message,
timeout= 5 ,
app_name= "My Notification" ,
app_icon= str (curr_path)+ "\\icon.ico" ,
)
time.sleep( 15 )
Here is the final result:
Follow me #techelopment
Medium: @techelopment
Dev.to: Techelopment
facebook: Techelopment
instagram: @techelopment
X: techelopment
telegram: @techelopment_channel
youtube: @techelopment
whatsapp: Techelopment
Top comments (0)