Merge branch 'linux' into master

This commit is contained in:
DevilXD committed 2022-11-30 22:15:38 +01:00
1 parent 94efa44f96
commit d3b9a76b5a
4 files changed
+34 -26

No files matched your search

+18 -6
View File
@@ -12,22 +12,27 @@ from dataclasses import dataclass
from tkinter.font import Font, nametofont from tkinter.font import Font, nametofont
from functools import partial, cached_property from functools import partial, cached_property
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
from tkinter import Tk, ttk, StringVar, DoubleVar, IntVar, PhotoImage from tkinter import Tk, ttk, StringVar, DoubleVar, IntVar
from typing import Any, Union, Tuple, TypedDict, NoReturn, Generic, TYPE_CHECKING from typing import Any, Union, Tuple, TypedDict, NoReturn, Generic, TYPE_CHECKING
import pystray import pystray
import win32api
import win32con
import win32gui
from yarl import URL from yarl import URL
from PIL.ImageTk import PhotoImage
from PIL import Image as Image_module from PIL import Image as Image_module
if sys.platform == "win32":
import win32api
import win32con
import win32gui
from translate import _ from translate import _
from cache import ImageCache from cache import ImageCache
from exceptions import ExitRequest from exceptions import ExitRequest
from utils import resource_path, Game, _T from utils import resource_path, Game, _T
from registry import RegistryKey, ValueType
from constants import SELF_PATH, FORMATTER, WS_TOPICS_LIMIT, MAX_WEBSOCKETS, WINDOW_TITLE, State from constants import SELF_PATH, FORMATTER, WS_TOPICS_LIMIT, MAX_WEBSOCKETS, WINDOW_TITLE, State
if sys.platform == "win32":
from registry import RegistryKey, ValueType
if TYPE_CHECKING: if TYPE_CHECKING:
from twitch import Twitch from twitch import Twitch
@@ -1502,6 +1507,7 @@ class SettingsPanel:
tray = bool(self._vars["tray"].get()) tray = bool(self._vars["tray"].get())
self._settings.autostart = enabled self._settings.autostart = enabled
self._settings.autostart_tray = tray self._settings.autostart_tray = tray
if sys.platform == "win32":
if enabled: if enabled:
# NOTE: we need double quotes in case the path contains spaces # NOTE: we need double quotes in case the path contains spaces
self_path = f'"{SELF_PATH.resolve()!s}"' self_path = f'"{SELF_PATH.resolve()!s}"'
@@ -1711,7 +1717,13 @@ class GUIManager:
# withdraw immediately to prevent the window from flashing # withdraw immediately to prevent the window from flashing
self._root.withdraw() self._root.withdraw()
# root.resizable(False, True) # root.resizable(False, True)
root.iconbitmap(resource_path("pickaxe.ico")) # window icon root.iconphoto( # window icon
True,
PhotoImage(
master=root,
image=Image_module.open(resource_path("pickaxe.ico")),
)
)
root.title(WINDOW_TITLE) # window title root.title(WINDOW_TITLE) # window title
root.bind_all("<KeyPress-Escape>", self.unfocus) # pressing ESC unfocuses selection root.bind_all("<KeyPress-Escape>", self.unfocus) # pressing ESC unfocuses selection
# Image cache for displaying images # Image cache for displaying images
+11 -18
View File
@@ -17,23 +17,11 @@ if __name__ == "__main__":
from tkinter import messagebox from tkinter import messagebox
from typing import IO, NoReturn from typing import IO, NoReturn
# pre-import 3rd party libraries, handling missing ones with an exception from PIL.ImageTk import PhotoImage
try: from PIL import Image as Image_module
import aiohttp # noqa
except ModuleNotFoundError as exc: if sys.platform == "win32":
raise ImportError("You have to run 'pip install aiohttp' first") from exc import win32gui
try:
import pystray # noqa
except ModuleNotFoundError as exc:
raise ImportError("You have to run 'pip install pystray' first") from exc
try:
import PIL # noqa
except ModuleNotFoundError as exc:
raise ImportError("You have to run 'pip install pillow' first") from exc
try:
import win32gui # noqa
except ModuleNotFoundError as exc:
raise ImportError("You have to run 'pip install pywin32' first") from exc
from translate import _ from translate import _
from twitch import Twitch from twitch import Twitch
@@ -103,7 +91,9 @@ if __name__ == "__main__":
root = tk.Tk() root = tk.Tk()
root.overrideredirect(True) root.overrideredirect(True)
root.withdraw() root.withdraw()
root.iconbitmap(resource_path("pickaxe.ico")) root.iconphoto(
True, PhotoImage(master=root, image=Image_module.open(resource_path("pickaxe.ico")))
)
root.update() root.update()
parser = Parser( parser = Parser(
SELF_PATH.name, SELF_PATH.name,
@@ -135,8 +125,11 @@ if __name__ == "__main__":
sys.exit(4) sys.exit(4)
# dummy window isn't needed anymore # dummy window isn't needed anymore
root.destroy() root.destroy()
# get rid of unneeded objects
del root, parser
# check if we're not already running # check if we're not already running
if sys.platform == "win32":
try: try:
exists = win32gui.FindWindow(None, WINDOW_TITLE) exists = win32gui.FindWindow(None, WINDOW_TITLE)
except AttributeError: except AttributeError:
+2 -1
View File
@@ -1,7 +1,8 @@
aiohttp>2.0,<4.0 aiohttp>2.0,<4.0
Pillow Pillow
pystray pystray
pywin32
selenium-wire selenium-wire
# use a fork that has an extra option of hiding the unneeded Chrome's console cmd window # use a fork that has an extra option of hiding the unneeded Chrome's console cmd window
git+https://github.com/sebdelsol/undetected-chromedriver git+https://github.com/sebdelsol/undetected-chromedriver
# this is installed only on windows
pywin32; sys_platform == "win32"
+3 -1
View File
@@ -9,12 +9,14 @@ import logging
from time import time from time import time
from itertools import chain from itertools import chain
from functools import partial from functools import partial
from subprocess import CREATE_NO_WINDOW
from collections import abc, deque, OrderedDict from collections import abc, deque, OrderedDict
from datetime import datetime, timedelta, timezone from datetime import datetime, timedelta, timezone
from contextlib import suppress, asynccontextmanager from contextlib import suppress, asynccontextmanager
from typing import Any, Literal, Final, NoReturn, overload, cast, TYPE_CHECKING from typing import Any, Literal, Final, NoReturn, overload, cast, TYPE_CHECKING
if sys.platform == "win32":
from subprocess import CREATE_NO_WINDOW
import aiohttp import aiohttp
from yarl import URL from yarl import URL
try: try: