diff --git a/.vscode/launch.json b/.vscode/launch.json index 9604a53..1d5a4ef 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -20,6 +20,15 @@ "console": "integratedTerminal", "justMyCode": false }, + { + "name": "Run App (INFO+Tray)", + "type": "python", + "request": "launch", + "program": "main.py", + "args": ["--no-run-check", "-vv", "--tray"], + "console": "integratedTerminal", + "justMyCode": false + }, { "name": "Run App (DEBUG)", "type": "python", @@ -46,14 +55,5 @@ "console": "integratedTerminal", "justMyCode": false }, - { - "name": "Test ArgParser", - "type": "python", - "request": "launch", - "program": "main.py", - "args": ["--excludes", "1", "2", "3"], - "console": "integratedTerminal", - "justMyCode": false - }, ] } diff --git a/gui.py b/gui.py index dd20ac2..90f9123 100644 --- a/gui.py +++ b/gui.py @@ -891,9 +891,6 @@ class TrayIcon: self.icon: pystray.Icon | None = None self._button = ttk.Button(master, command=self.minimize, text="Minimize to Tray") self._button.grid(column=0, row=0, sticky="ne") - if manager._twitch.settings.tray: - # start hidden in tray - self._manager._root.after_idle(self.minimize) def is_tray(self) -> bool: return self.icon is not None @@ -1284,8 +1281,11 @@ class GUIManager: self._handler = _TKOutputHandler(self) self._handler.setFormatter(FORMATTER) logging.getLogger("TwitchDrops").addHandler(self._handler) - # show the window when ready - if not self._twitch.settings.tray: + # stay hidden in tray if needed, otherwise show the window when everything's ready + if self._twitch.settings.tray: + # NOTE: this starts the tray icon thread + self._root.after_idle(self.tray.minimize) + else: self._root.deiconify() # https://stackoverflow.com/questions/56329342/tkinter-treeview-background-tag-not-working