Fix the tray command line option not working

This commit is contained in:
DevilXD
2022-03-17 11:28:17 +01:00
parent 12fdf7ab96
commit ccf7fbf96d
2 changed files with 14 additions and 14 deletions

18
.vscode/launch.json vendored
View File

@@ -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
},
]
}

10
gui.py
View File

@@ -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