mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-13 07:47:14 +03:00
Added windows OS checks
This commit is contained in:
parent
6c0437642e
commit
fa58d2f0c2
@ -9,7 +9,6 @@ import locale
|
||||
import pathlib
|
||||
import re
|
||||
import sys
|
||||
import threading
|
||||
import webbrowser
|
||||
from builtins import object, str
|
||||
from os import chdir, environ
|
||||
@ -18,8 +17,6 @@ from sys import platform
|
||||
from time import localtime, strftime, time
|
||||
from typing import TYPE_CHECKING, Optional, Tuple
|
||||
|
||||
from infi.systray import SysTrayIcon
|
||||
|
||||
# Have this as early as possible for people running EDMarketConnector.exe
|
||||
# from cmd.exe or a bat file or similar. Else they might not be in the correct
|
||||
# place for things like config.py reading .gitversion
|
||||
@ -333,17 +330,21 @@ class AppWindow(object):
|
||||
|
||||
self.prefsdialog = None
|
||||
|
||||
self.only_tray_close = 0
|
||||
if platform == 'win32':
|
||||
import threading
|
||||
from infi.systray import SysTrayIcon
|
||||
|
||||
def open_window(systray) -> None:
|
||||
self.only_tray_close = 2
|
||||
shutdown_thread = threading.Thread(target=systray.shutdown)
|
||||
shutdown_thread.setDaemon(True)
|
||||
shutdown_thread.start()
|
||||
self.w.deiconify()
|
||||
self.only_tray_close = 0
|
||||
|
||||
menu_options = (("Open", None, open_window),)
|
||||
self.systray = SysTrayIcon("EDMarketConnector.ico", applongname, menu_options, on_quit=self.exit_tray)
|
||||
def open_window(systray) -> None:
|
||||
self.only_tray_close = 2
|
||||
shutdown_thread = threading.Thread(target=systray.shutdown)
|
||||
shutdown_thread.setDaemon(True)
|
||||
shutdown_thread.start()
|
||||
self.w.deiconify()
|
||||
|
||||
menu_options = (("Open", None, open_window),)
|
||||
self.systray = SysTrayIcon("EDMarketConnector.ico", applongname, menu_options, on_quit=self.exit_tray)
|
||||
|
||||
plug.load_plugins(master)
|
||||
|
||||
@ -1388,17 +1389,22 @@ class AppWindow(object):
|
||||
|
||||
def onexit(self, event=None) -> None:
|
||||
"""Application shutdown procedure."""
|
||||
value = bool(config.get_int('close_system_tray'))
|
||||
if platform == 'win32':
|
||||
value = bool(config.get_int('close_system_tray'))
|
||||
|
||||
if value:
|
||||
self.w.withdraw()
|
||||
self.systray.start()
|
||||
if value:
|
||||
self.w.withdraw()
|
||||
self.systray.start()
|
||||
|
||||
else:
|
||||
self.exit()
|
||||
|
||||
else:
|
||||
self.exit()
|
||||
|
||||
def exit_tray(self, systray) -> None:
|
||||
"""Tray icon is shutting down."""
|
||||
import threading
|
||||
if self.only_tray_close > 0:
|
||||
self.only_tray_close -= 1
|
||||
|
||||
|
14
prefs.py
14
prefs.py
@ -792,13 +792,13 @@ class PreferencesDialog(tk.Toplevel):
|
||||
)
|
||||
self.ontop_button.grid(columnspan=3, padx=self.BUTTONX, sticky=tk.W, row=row.get()) # Appearance setting
|
||||
|
||||
self.system_tray_button = nb.Checkbutton(
|
||||
appearance_frame,
|
||||
text=_('Close to system tray'),
|
||||
variable=self.close_system_tray,
|
||||
command=self.themevarchanged
|
||||
)
|
||||
self.system_tray_button.grid(columnspan=3, padx=self.BUTTONX, sticky=tk.W, row=row.get()) # Appearance setting
|
||||
if platform == 'win32':
|
||||
nb.Checkbutton(
|
||||
appearance_frame,
|
||||
text=_('Close to system tray'),
|
||||
variable=self.close_system_tray,
|
||||
command=self.themevarchanged
|
||||
).grid(columnspan=3, padx=self.BUTTONX, sticky=tk.W, row=row.get()) # Appearance setting
|
||||
|
||||
nb.Label(appearance_frame).grid(sticky=tk.W) # big spacer
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
certifi==2020.12.5
|
||||
requests==2.25.1
|
||||
watchdog==2.0.3
|
||||
infi.systray==0.1.12
|
||||
infi.systray==0.1.12; sys_platform == 'win32'
|
||||
# argh==0.26.2 watchdog dep
|
||||
# pyyaml==5.3.1 watchdog dep
|
||||
semantic-version==2.8.5
|
||||
|
Loading…
x
Reference in New Issue
Block a user