Jer*_*and 5 python notifications toast python-3.x windows-10
我正在尝试通过https://github.com/jithurjacob/Windows-10-Toast-Notifications/提供的 win10toast python 库在 Windows 10 中发送一些 toast 通知。当我使用此库发送消息时,我可以在屏幕右下角看到通知一段时间,并且在显示该通知时操作中心中有一个条目。但是,一旦该通知消退(由于未采取任何操作,大约 5 秒后),操作中心中的条目也会消失。如何使通知在操作中心持续存在而不是在不采取任何行动时消失?
这是我迄今为止尝试过的...
这里的任何指导将不胜感激!
您可以使用这个名为winrt的 python 模块。
#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)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
676 次 |
| 最近记录: |