Skip to content

Commit

Permalink
feat: icon for gui
Browse files Browse the repository at this point in the history
  • Loading branch information
WyvernIXTL committed Nov 7, 2024
1 parent abef182 commit 7d18e8f
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions gamepadla_plus/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 15 additions & 4 deletions gamepadla_plus/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand All @@ -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")],
Expand All @@ -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))],
[
Expand All @@ -59,7 +68,7 @@ def license_popup():

def upload_popup(data: dict):
window = sg.Window(
"Upload",
"Upload Results",
[
[sg.Text("Connection Type")],
[
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion icon/compile.ps1
Original file line number Diff line number Diff line change
@@ -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
magick ./gamepadla-plus.png -background transparent -define icon:auto-resize=16,24,32,48,64,72,96,128,256 gamepadla-plus.ico
File renamed without changes

0 comments on commit 7d18e8f

Please sign in to comment.