Skip to content

Commit 152792a

Browse files
committed
prepared app for release
1 parent 01c80cd commit 152792a

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ jobs:
3838

3939
- name: Build with PyInstaller
4040
run: |
41-
pyinstaller --onefile client.py
41+
pyinstaller --onefile --noconsole --clean --add-data "icon.png:." main.py
42+
shell: bash
4243

4344
- name: Rename binary
4445
run: |
45-
mv dist/client${{ matrix.ext }} board-game-client-${{ matrix.os }}${{ matrix.ext }}
46+
mv dist/main${{ matrix.ext }} wp-changer-${{ matrix.os }}${{ matrix.ext }}
4647
shell: bash
4748

4849
- name: Make binary executable (macOS)

application.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from scheduler import TkScheduler
77
from api import WallhavenAPI
88
from tray import TrayIcon
9-
9+
from lib import resource_path
1010

1111
class App:
1212
def __init__(self, _root: tk.Tk, interval_seconds: int):
@@ -71,7 +71,7 @@ def _setup_root(self):
7171
self.root.attributes("-toolwindow", True)
7272

7373
try:
74-
icon = tk.PhotoImage(file="icon.png")
74+
icon = tk.PhotoImage(file=resource_path("icon.png"))
7575
self.root.iconphoto(True, icon)
7676
except Exception as e:
7777
print("Could not load app icon:", e)

lib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import platform
33
import subprocess # macOS only
44
import ctypes
5+
import sys
56

67

78
def set_wallpaper(path: str):
@@ -18,3 +19,9 @@ def set_wallpaper(path: str):
1819
subprocess.run(["osascript", "-e", script], check=True)
1920
else:
2021
raise NotImplementedError("Setting wallpaper is not implemented for this OS.")
22+
23+
24+
def resource_path(relative_path: str) -> str:
25+
if hasattr(sys, "_MEIPASS"):
26+
return os.path.join(sys._MEIPASS, relative_path)
27+
return os.path.join(os.path.abspath("."), relative_path)

tray.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pystray
77
from pystray import MenuItem as Item
88
import platform
9+
from lib import resource_path
910

1011
if TYPE_CHECKING:
1112
from application import App
@@ -24,7 +25,7 @@ def _cb(icon, item):
2425
return _cb
2526

2627
def _create_tray_icon(self):
27-
image = Image.open("icon.png")
28+
image = Image.open(resource_path("icon.png"))
2829

2930
menu = pystray.Menu(
3031
Item("Start Slideshow", self._wrap(self.app.start_slideshow)),

0 commit comments

Comments
 (0)