使用python中的图像赢得10个toast通知

2024-05-20 00:54:50 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有办法在Windows10中使用python创建交互式toast通知? 目前我正在使用plyer,有时我使用win10toast。 当有人单击它时,我希望它在web浏览器中打开一个页面,并包含图像、图标、文本和用户输入


Tags: 用户图像文本web浏览器页面图标办法
2条回答

对于图像部分,可以使用如下模块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)

另外,有三个地方可以放置图像:AppLogoOverrideInlineHero

我翻遍了win10toast的source code,发现他们使用this library创建windows gui元素,here是最新的版本。在那里,您应该能够找到正确的模块来使用

相关问题 更多 >