Skip to content

Commit e5d0fff

Browse files
committed
fix: update build process to include logo for PyInstaller
1 parent 5b26caa commit e5d0fff

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

.github/workflows/build-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
pip install pyinstaller
2222
2323
- name: Build EXE with PyInstaller
24-
run: pyinstaller --onefile gui.py
24+
run: pyinstaller --onefile --add-data "media/3-2-2_inverted_logo_waterlinked.png;media" gui.py
2525

2626
- name: Wait for EXE and Move
2727
shell: pwsh

gui.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
import sys
13
import json
24
import threading
35
import time
@@ -10,6 +12,14 @@
1012
logger = logging.getLogger(__name__)
1113
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(filename)s:%(lineno)d=%(levelname)s:%(message)s')
1214

15+
def resource_path(relative_path):
16+
"""
17+
Get absolute path to resource, needed for pyinstaller to find resources.
18+
"""
19+
if hasattr(sys, '_MEIPASS'):
20+
return os.path.join(sys._MEIPASS, relative_path)
21+
return os.path.join(os.path.abspath("."), relative_path)
22+
1323
class M16GUI(tk.Tk):
1424
def __init__(self):
1525
super().__init__()
@@ -22,7 +32,7 @@ def __init__(self):
2232

2333
def create_widgets(self) -> None:
2434
"""
25-
Create the layout of the GUI app
35+
Create the layout of the GUI app.
2636
"""
2737
# Create a ttk style for caption labels
2838
style = ttk.Style()
@@ -53,7 +63,8 @@ def create_widgets(self) -> None:
5363
logo_frame.grid(row=0, column=0, padx=5, pady=5, sticky="nw")
5464

5565
# Load and scale the logo image
56-
logo = PhotoImage(file="media/3-2-2_inverted_logo_waterlinked.png")
66+
image_path = resource_path("media/3-2-2_inverted_logo_waterlinked.png")
67+
logo = PhotoImage(file=image_path)
5768
scale_factor = 17 # Adjust as needed
5869
logo_small = logo.subsample(scale_factor, scale_factor)
5970

0 commit comments

Comments
 (0)