3

Is there a way to create an interactive toast notification in windows 10 using python? Currently I am using plyer and sometimes I use win10toast. When someone clicks it i want it to open a page in the web browser and contain an image, icon, text, and user input

Bugbeeb
  • 2,021
  • 1
  • 9
  • 26
Sashank
  • 557
  • 6
  • 20

2 Answers2

1

I rummaged through the source code for win10toast and found they use this library for creating windows gui elements and here is the most recent release. There you should be able to find the right module to use

Bugbeeb
  • 2,021
  • 1
  • 9
  • 26
1

For the Image part, You can use the module winrt like this:

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)

Also, There three places where you can put an image: AppLogoOverride, Inline and Hero.

N3RDIUM
  • 358
  • 5
  • 22