【问题标题】:Python toast notifications not propagating to Action CenterPython toast 通知未传播到操作中心
【发布时间】:2018-04-21 14:32:17
【问题描述】:

我正在尝试通过https://github.com/jithurjacob/Windows-10-Toast-Notifications/ 提供的 win10toast python 库在 Windows 10 中发送一些 toast 通知。当我使用这个库发送消息时,我可以在屏幕右下角看到一段时间的通知,并且在显示该通知时,操作中心中有一个条目。但是,一旦通知消退(大约 5 秒后,由于未采取任何操作),操作中心中的条目也会消失。如何让通知在操作中心持续存在而不是在未采取任何操作时消失?

到目前为止,这是我尝试过的...

  • 注册更改基于 Windows Toast Notification not showing in Action Center 。虽然,我无法确定注册密钥使用什么应用程序名称。

  • 基于Why is this simple python toast notification not working?的设置审核。启用“从应用程序和其他发件人获取通知”设置。我在“发送者”设置部分下的应用程序列表中看不到任何指示此库、应用程序或 Python 的内容。

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

  • 【问题讨论】:

      标签: python python-3.x notifications windows-10 toast


      【解决方案1】:

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

      【讨论】:

        猜你喜欢
        • 2016-09-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-09-26
        • 1970-01-01
        • 1970-01-01
        • 2017-06-02
        相关资源
        最近更新 更多