Reputation: 51
I'm trying to send some toast notifications in Windows 10 via the win10toast python library provided at https://github.com/jithurjacob/Windows-10-Toast-Notifications/. When I send a message using this library, I'm able to see the notification in the lower right corner of my screen for awhile, and there is an entry in Action Center while that notification is displayed. However, once that notification subsides (after about 5 seconds due to no action taken), the entry in Action Center also disappears. How do I make the notification persist in Action Center rather than disappear when no action is taken?
Here's what I've tried so far...
Any guidance here would be greatly appreciated!
Upvotes: 5
Views: 885
Reputation: 366
You can use this python module called winrt.
#importing required modules
import winrt.windows.ui.notifications as notifications
import winrt.windows.data.xml.dom as dom
from time import sleep
# create notification objects
nManager = notifications.ToastNotificationManager
notifier = nManager.create_toast_notifier(r"C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\python.exe")
# PUT YOUR USERNAME INSTEAD OF USERNAME
# put your python path there.
# define the xml notification document.
tString = """
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Another Message from Tim!</text>
<text>Hi there!</text>
</binding>
</visual>
</toast>
"""
# load the xml document.
xDoc = dom.XmlDocument()
xDoc.load_xml(tString)
notification = notifications.ToastNotification(xDoc)
# display notification
notifier.show(notification)
Upvotes: 0