You can use this package to handle notifications for the system
pip install win10toast
Make sure you had pip in your system to check it is available or not use the command
pip -- version in the command line if it is available in your system you can proceed with the first command, If not try installing pip by this link.
After installing the win10toast package
Import the package into your program there are many classes in this package like ToastNotifier, CreateWindow, DestroyWindow, UpdateWindow, load image ...etc
We use ToastNotifier class this class had 3 methods in it
- notification_active
- on_destroy
- show_toast
1) notification_active() :
SYNTAX : ToastNotifier().notification_active()
This method returns whether an active notification shown in the system or not
1 2 3 | from win10toast import ToastNotifier toast = ToastNotifier() toast.notification_active() |
Output:
False
2) on_destroy() :
SYNTAX : ToastNotifier().on_destroy(hwnd,msg,wparam,lparam)
This method cleans after the notification ended 4 parameters are required
for the on_destroy method.
3) show_toast() :
SYNTAX : show_toast(title,msg,icon_path,duration,threaded)
1 2 3 | from win10toast import ToastNotifier toast = ToastNotifier() toast.show_toast("Instagram","Follow pythonblog for more updates",duration=20) |
OUTPUT :
Notification will be seen in the system
No comments