Python Toast 通知未传播到操作中心

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 秒后),操作中心中的条目也会消失。如何使通知在操作中心持续存在而不是在不采取任何行动时消失?

这是我迄今为止尝试过的...

  • 基于Windows Toast 通知的注册更改未显示在操作中心。虽然,我无法确定用于注册密钥的应用程序名称。

  • 基于为什么这个简单的 python toast 通知不起作用的设置审查. 设置“从应用程序和其他发件人获取通知”已启用。在“发送者”设置部分下,我在我的应用程序列表中没有看到任何指示此库、应用程序或 Python 的内容。

    这里的任何指导将不胜感激!

  • N3R*_*IUM 0

    您可以使用这个名为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)