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 plyerpip install plyerpip install plyer
Enter fullscreen mode Exit fullscreen mode
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 notificationfrom plyer import notificationfrom plyer import notification
Enter fullscreen mode Exit fullscreen mode
The function to use will be notification.notify, its main parameters are (full docs here):
title (str) - Title of the notificationmessage (str) - Message contained within the notificationapp_name (str) - Name of the applicationapp_icon (str) - Icon to display next to the notification messagetimeout (int) - Time to display the notification in seconds (default 10)ticker (str) - Text to display in the notification bartitle (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 bartitle (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
Enter fullscreen mode Exit fullscreen mode
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 timeimport pathlibfrom plyer import notificationcurr_path = pathlib.Path(__file__).resolve().parentnotification_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 )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 )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 )
Enter fullscreen mode Exit fullscreen mode
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
暂无评论内容