python - 当我尝试使用 winrt 发出通知时,没有显示通知
问题描述
我正在尝试让 winRT 发送通知。我尝试这样做以发出通知:
import winrt.windows.ui.notifications as notifications
import winrt.windows.data.xml.dom as dom
#create notifier
nManager = notifications.ToastNotificationManager
notifier = nManager.create_toast_notifier("app-id");
tString = """
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Sample toast</text>
<text>Sample content</text>
</binding>
</visual>
</toast>
"""
#convert notification to an XmlDocument
xDoc = dom.XmlDocument()
xDoc.load_xml(tString)
#display notification
notifier.show(notifications.ToastNotification(xDoc))
但是,当我运行它时,没有任何通知出现。
我的系统符合winrt的要求
Windows 10, October 2018 Update or later.
Python for Windows, version 3.7 or later
pip, version 19 or later
如何让通知显示?我不能使用其他模块,因为 winrt 是唯一一个(据我所知),您可以在其中创建按钮等通知上的 ui 元素。我认为 Windows 不会阻止它显示,因为其他不符合我要求的模块会显示通知。
解决方案
推荐阅读
- javascript - jQuery Datepicker onClose 上的 SetDate 不会改变值
- mongodb - 如何通过 mongo-go-driver 获取集合的大小
- python - 非素数只包含 2,3,5,7 优化
- excel - 无法进行 VBA 查找
- excel-formula - Excel 公式 - 基于月流失率的第 N 年后的总订阅量
- html - 删除页脚底部的空白
- xml - 如何从第二个 XML 文件中获取正确的值?
- python - _tkinter.TclError:未知选项“-image”
- angular - 使用谷歌角度获取城市建议
- jenkins - 从脚本控制台删除文件夹内所有作业的旧版本