Search code examples
pythonpython-3.xwindowsnotificationstoast

Regarding win10toast and win10toast-click, I have an issue with the Notification Center


I have an issue regarding Python and Windows 10 toast notifications. What I would like to do is a windows toast that can be clickable AND that goes in the notification center if I don't click on it.

I know the existence of both win10toast and win10toast-click. The issue is that win10toast doesn't support callback_on_click and win10toast-click doesn't support the Duration=None parameter which allows the notification to go into the Notification Center if not clicked. I would like to find an easy way to do both but I unfortunately can't since I don't have the skills required to merge these two libraries.

Here is the code :

from win10toast-click import ToastNotifier

def test():
  print('test')

toast = ToastNotifier()
toast.show_toast(
    'Notification title',
    'Notification body',
    duration=None,
    icon_path='icon.ico',
    callback_on_click=test
) # Does not stand in the Notification Center
from win10toast import ToastNotifier

def test():
  print('test')

toast = ToastNotifier()
toast.show_toast(
    'Notification title', 
    'Notification body', 
    duration=None, 
    icon_path='icon.ico'
) # Stands in the Notification Center but does not support callback 

Any of you have an idea ? Thank you in advance...


Solution

  • Okay so, for anyone having the same issue as me, I just found the perfect solution that does everything you intend to.

    There is a recent library called winotify which stands in the notification center, is HIGHLY CUSTOMIZABLE and can open links to your default browser.

    Throw away win10toast and go for winotify!

    Source code: winotify's GitHub page