Merge branch 'linux' into master
This commit is contained in:
1 parent
94efa44f96
commit
d3b9a76b5a
4 files changed
+52
-44
No files matched your search
@@ -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,16 +1507,17 @@ 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 enabled:
|
if sys.platform == "win32":
|
||||||
# NOTE: we need double quotes in case the path contains spaces
|
if enabled:
|
||||||
self_path = f'"{SELF_PATH.resolve()!s}"'
|
# NOTE: we need double quotes in case the path contains spaces
|
||||||
if tray:
|
self_path = f'"{SELF_PATH.resolve()!s}"'
|
||||||
self_path += " --tray"
|
if tray:
|
||||||
with RegistryKey(self.AUTOSTART_KEY) as key:
|
self_path += " --tray"
|
||||||
key.set(self.AUTOSTART_NAME, ValueType.REG_SZ, self_path)
|
with RegistryKey(self.AUTOSTART_KEY) as key:
|
||||||
else:
|
key.set(self.AUTOSTART_NAME, ValueType.REG_SZ, self_path)
|
||||||
with RegistryKey(self.AUTOSTART_KEY) as key:
|
else:
|
||||||
key.delete(self.AUTOSTART_NAME, silent=True)
|
with RegistryKey(self.AUTOSTART_KEY) as key:
|
||||||
|
key.delete(self.AUTOSTART_NAME, silent=True)
|
||||||
|
|
||||||
def set_games(self, games: abc.Iterable[Game]) -> None:
|
def set_games(self, games: abc.Iterable[Game]) -> None:
|
||||||
games_list = sorted(map(str, games))
|
games_list = sorted(map(str, games))
|
||||||
@@ -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
|
||||||
|
|||||||
@@ -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,16 +125,19 @@ 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
|
||||||
try:
|
if sys.platform == "win32":
|
||||||
exists = win32gui.FindWindow(None, WINDOW_TITLE)
|
try:
|
||||||
except AttributeError:
|
exists = win32gui.FindWindow(None, WINDOW_TITLE)
|
||||||
# we're not on Windows - continue
|
except AttributeError:
|
||||||
exists = False
|
# we're not on Windows - continue
|
||||||
if exists and not settings.no_run_check:
|
exists = False
|
||||||
# already running - exit
|
if exists and not settings.no_run_check:
|
||||||
sys.exit(3)
|
# already running - exit
|
||||||
|
sys.exit(3)
|
||||||
|
|
||||||
# set language
|
# set language
|
||||||
try:
|
try:
|
||||||
|
|||||||
+2
-1
@@ -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"
|
||||||
@@ -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:
|
||||||
|
|||||||
Reference in new issue
Block a user