有没有办法使用 python 在 Windows 10 中创建交互式 toast 通知?
目前我正在使用 plyer
,有时我会使用 win10toast
。
当有人点击它时,我希望它在网络浏览器中打开一个页面并包含图像、图标、文本和用户输入
最佳答案
对于图像部分,您可以使用模块 winrt像这样:
import winrt.windows.ui.notifications as notifications
import winrt.windows.data.xml.dom as dom
nManager = notifications.ToastNotificationManager
notifier = nManager.create_toast_notifier(r"C:\Users\Admin\AppData\Local\Programs\Python\Python38\python.exe")
tString = """
<toast>
<visual>
<binding template='ToastGeneric'>
<text>Another Message from Tim!</text>
<text>Hi there!</text>
<image placement="appLogoOverride" hint-crop="circle" src="https://picsum.photos/48?image=883"/>
</binding>
</visual>
</toast>
"""
xDoc = dom.XmlDocument()
xDoc.load_xml(tString)
notification = notifications.ToastNotification(xDoc)
#display notification
notifier.show(notification)
此外,您可以在三个地方放置图像:AppLogoOverride , Inline和 Hero .
关于python - 用 python 中的图像赢得 10 个 toast 通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62826794/