diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 5740159..5b8bae5 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -56,7 +56,9 @@ jobs: --recursive-copy-metadata gamepadla_plus --collect-all gamepadla_plus --add-data "LICENSE.txt;." - --add-data "THIRD-PARTY-LICENSES.txt;." + --add-data "THIRD-PARTY-LICENSES.txt;." + --add-data "icon/gamepadla-plus.ico;icon/." + --add-data "icon/gamepadla-plus.png;icon/." --hide-console hide-late --noupx --icon .\icon\gamepadla-plus.ico diff --git a/gamepadla_plus/common.py b/gamepadla_plus/common.py index 0819b39..2b16bb3 100644 --- a/gamepadla_plus/common.py +++ b/gamepadla_plus/common.py @@ -215,9 +215,13 @@ def write_to_file(data: dict, path: str): json.dump(data, outfile, indent=4) -def read_license(license_file_name: str) -> str: +def project_root_path() -> str: src_path = os.path.dirname(os.path.realpath(__file__)) - license_path = src_path + "/../" + license_file_name + return src_path + "/../" + + +def read_license(license_file_name: str) -> str: + license_path = project_root_path() + license_file_name if os.path.exists(license_path): with open(license_path, "r", errors="ignore") as license_file: license_text = license_file.read() diff --git a/gamepadla_plus/gui.py b/gamepadla_plus/gui.py index 02b596e..4f7acba 100644 --- a/gamepadla_plus/gui.py +++ b/gamepadla_plus/gui.py @@ -3,6 +3,7 @@ from pygame.joystick import JoystickType from rich.traceback import install as traceback_install import FreeSimpleGUI as sg +from sys import platform from gamepadla_plus.__init__ import LICENSE_FILE_NAME, THIRD_PARTY_LICENSE_FILE_NAME from gamepadla_plus.common import ( @@ -15,9 +16,17 @@ test_execution, wrap_data_for_server, read_license, + project_root_path, ) +def get_icon_path() -> str: + if platform == "win32": + return project_root_path() + "icon/gamepadla-plus.ico" + else: + return project_root_path() + "icon/gamepadla-plus.png" + + def error_popup(msg: str): sg.Window("Error", [[sg.Text(msg)], [sg.Push(), sg.Button("Continue")]]).read( close=True @@ -26,7 +35,7 @@ def error_popup(msg: str): def third_party_license_popup(licenses: str): sg.Window( - "Error", + "3rd Party Licenses", [ [sg.Multiline(licenses, size=(100, 50), wrap_lines=True)], [sg.Push(), sg.Button("Continue")], @@ -37,7 +46,7 @@ def third_party_license_popup(licenses: str): def license_popup(): third_party_license = read_license(THIRD_PARTY_LICENSE_FILE_NAME) event, _ = sg.Window( - "Error", + "License", [ [sg.Text(read_license(LICENSE_FILE_NAME))], [ @@ -59,7 +68,7 @@ def license_popup(): def upload_popup(data: dict): window = sg.Window( - "Upload", + "Upload Results", [ [sg.Text("Connection Type")], [ @@ -222,7 +231,9 @@ def gui(): ], ] - window = sg.Window("Gamepadla+", layout, finalize=True, size=(400, 560)) + window = sg.Window( + "Gamepadla+", layout, finalize=True, size=(400, 560), icon=get_icon_path() + ) def update_joysticks(): nonlocal joysticks diff --git a/icon/compile.ps1 b/icon/compile.ps1 index 8169b32..d67ab89 100644 --- a/icon/compile.ps1 +++ b/icon/compile.ps1 @@ -1 +1 @@ -magick ./gamepadla-plus-icon-export.png -background transparent -define icon:auto-resize=16,24,32,48,64,72,96,128,256 gamepadla-plus.ico \ No newline at end of file +magick ./gamepadla-plus.png -background transparent -define icon:auto-resize=16,24,32,48,64,72,96,128,256 gamepadla-plus.ico \ No newline at end of file diff --git a/icon/gamepadla-plus-icon-export.png b/icon/gamepadla-plus.png similarity index 100% rename from icon/gamepadla-plus-icon-export.png rename to icon/gamepadla-plus.png