Skip to content

Commit 581d168

Browse files
committed
Refactor stylesheet loading to use resource path for compatibility with PyInstaller
1 parent 4b9ef7a commit 581d168

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,18 @@ def __init__(self, name, display_name, section_title, placeholder, help_text,
2525
self.output_suffix = output_suffix
2626

2727

28+
def resource_path(relative_path):
29+
""" Get absolute path to resource, works for dev and for PyInstaller """
30+
# PyInstaller creates a temp folder and stores path in _MEIPASS
31+
base_path = getattr(sys, '_MEIPASS', os.path.abspath("."))
32+
return os.path.join(base_path, relative_path)
33+
34+
2835
def load_stylesheet():
2936
"""Load the QSS stylesheet from a file."""
3037
try:
31-
with open("style.qss", "r") as f:
38+
stylesheet_path = resource_path("style.qss")
39+
with open(stylesheet_path, "r") as f:
3240
return f.read()
3341
except FileNotFoundError:
3442
print("Warning: style.qss not found. Using default styles.")

0 commit comments

Comments
 (0)