We can create a notifier for the events that occurred in Windows using Python. This is very simple with the win10toast module. If you are familiar with the Toast in Android then understanding the Toast notifications with Python is a piece of cake. We can generate notifications whenever an event occurs as a remainder. Let's see.
Run the following command in command-line to install win10toast module
pip install win10toast
If the module successfully installed then, you will get the following result when you run the command.
Collecting win10toast Downloading https://files.pythonhosted.org/packages/d4/ba/95c0ea87d9bcad68b90d8cb130a313b939c88d8338a2fed7c11eaee972fe/win10toast-0.9-py2.py3-none-any.whl Collecting pypiwin32 (from win10toast) Downloading https://files.pythonhosted.org/packages/d0/1b/2f292bbd742e369a100c91faa0483172cd91a1a422a6692055ac920946c5/pypiwin32-223-py3-none-any.whl Requirement already satisfied: setuptools in c:\users\hafeezulkareem\anaconda3\lib\site-packages (from win10toast) (40.8.0) Requirement already satisfied: pywin32>=223 in c:\users\hafeezulkareem\anaconda3\lib\site-packages (from pypiwin32->win10toast) (223) Installing collected packages: pypiwin32, win10toast Successfully installed pypiwin32-223 win10toast-0.9
Import ToastNotifier class from the win10toast.
Instantiate the class.
Invoke the show_toast('title', 'message', duration = time_in_sec, icon_path = 'path to .ico file') method with the desired arguments.
You will get True as output after notification duration complete, if successful.
Let's see it with a simple example.
## program to generate a simple toast notifier from win10toast import ToastNotifier ## instantiating the class notifier = ToastNotifier() ## invoking the show_toast() method with required arguments notifier.show_toast("Sample Notification", "You are learning at Tutorialspoint", duration = 25, icon_path = "globe.ico")
If you run the above program, you will get the following results.
You can add this notification program when an event occurs on your system. If you have any doubts regarding the tutorial, please mention them in the comment section.