'Notify on Windows via Python but not archive the notification

To notify that an error was encountered when running the code, I do it like this:

from plyer import notification

def notifyerror(notify_error_alert_text,time_appear):
    notification.notify(
        title = 'Visual Studio Code\nError:',
        message = notify_error_alert_text[:250],
        app_icon = None,
        timeout = time_appear,
    )
notifyerror('bla bla bla bla bla',1)

But as my need is only momentary and I don't need to see them in the future, I come across such a problem...

These notifications that appear on the screen are being archived and accumulating:

enter image description here

Is there any way to be able to notify via Python but without these notifications accumulating and only visually warning me at the moment and disappearing?



Solution 1:[1]

I found a way: to notify without archive the notification, a viable option for Windows 10 and Windows 11 is to use win10toast as ToastNotifier:

from win10toast import ToastNotifier

def notify_windows(notify_error_alert_text,time_appear):
    toaster = ToastNotifier()
    toaster.show_toast("Visual Studio Code",
                notify_error_alert_text[:250],
                icon_path=None,
                duration=time_appear,
                threaded=True)

notify_windows('bla bla bla bla bla',1)

In this example form, the notification appears and the code continues running without pauses, with the notification appearing for 1 second on the screen and disappearing without accumulating in the notification bar or hidden icons.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Digital Farmer