DatGuy1 / Windows-Toasts

Python library used to send toast notifications on Windows machines
Apache License 2.0
96 stars 6 forks source link

Removing specific toast only works with non-empty group #99

Closed DatGuy1 closed 3 months ago

DatGuy1 commented 1 year ago

This would be the code to remove a specific toast:

def remove_toast(self, toast: Toast) -> None:
    """
    Remove a toast. If it is currently displayed, it will immediately disappear.
    If it has been relegated to the action center, it will be removed from there.
    """
    toastNotificationHistory = ToastNotificationManager.history
    toastNotificationHistory.remove(toast.tag, toast.group, self._AUMID)

However, this only works if toast.group is a non-empty string. The question now is whether to set a default group (e.g. 'Toasts') on init of Toast, or try and figure out a workaround.