diff --git a/gui.py b/gui.py index dcbe035..7bc2584 100644 --- a/gui.py +++ b/gui.py @@ -727,6 +727,17 @@ class TrayIcon: self.stop() self._manager._root.deiconify() + def notify(self, message: str, title: Optional[str] = None, duration: float = 10): + if self._icon is not None: + icon = self._icon + + async def notifier(): + icon.notify(message, title) + await asyncio.sleep(duration) + icon.remove_notification() + + asyncio.create_task(notifier()) + class GUIManager: def __init__(self, twitch: Twitch): @@ -942,6 +953,10 @@ if __name__ == "__main__": gui.channels.set_watching(channel) gui._root.update() gui.channels.get_selection() + # Tray + # gui.tray.minimize() + # await asyncio.sleep(1) + # gui.tray.notify("Bounty Coins (3/7)", "Mined Drop") # Drop progress drop = create_drop("Wardrobe Cleaning", "Fancy Pants", 2, 7, 239, 240) gui.progress.display(drop) diff --git a/twitch.py b/twitch.py index fc0804a..409e5de 100644 --- a/twitch.py +++ b/twitch.py @@ -434,10 +434,12 @@ class Twitch: campaign = drop.campaign mined = await drop.claim() if mined: - self.gui.print( - f"Claimed drop: {drop.rewards_text()} " + claim_text = ( + f"{drop.rewards_text()} " f"({campaign.claimed_drops}/{campaign.total_drops})" ) + self.gui.print(f"Claimed drop: {claim_text}") + self.gui.tray.notify(claim_text, "Mined Drop") else: logger.error(f"Drop claim failed! Drop ID: {drop_id}") if not mined or campaign.remaining_drops == 0: