From cbb59c3e982d1e396e4ccc6d5d4c4bbb69ad1ff9 Mon Sep 17 00:00:00 2001 From: DevilXD Date: Sat, 2 Apr 2022 17:05:55 +0200 Subject: [PATCH] modify tray.notify to return a task for cancelling purposes --- gui.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gui.py b/gui.py index 36bbe3c..182b68c 100644 --- a/gui.py +++ b/gui.py @@ -824,7 +824,9 @@ class TrayIcon: self.stop() self._manager._root.deiconify() - def notify(self, message: str, title: str | None = None, duration: float = 10): + def notify( + self, message: str, title: str | None = None, duration: float = 10 + ) -> asyncio.Task[None] | None: if self.icon is not None: icon = self.icon @@ -833,7 +835,8 @@ class TrayIcon: await asyncio.sleep(duration) icon.remove_notification() - asyncio.create_task(notifier()) + return asyncio.create_task(notifier()) + return None def update_title(self, drop: TimedDrop): if self.icon is not None: