# Windows 10 Toast Notifications with Python

PythonServer Side ProgrammingProgramming

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
Collecting pypiwin32 (from win10toast)
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

## Steps To Create A Toast Notification

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

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

Published on 30-Aug-2019 16:25:21