Skip to content

Commit bf5ade2

Browse files
author
Bryan Howard
committed
Fix dark_theme.qss loading for both Python and compiled versions
- Replace hardcoded path with robust path resolution - Try multiple paths: current dir, ../dark_theme.qss, and absolute path - Works for compiled version (dark_theme.qss in root) - Works for development (run.bat from src/ directory needs ../dark_theme.qss) - Add descriptive logging when theme is loaded - Graceful fallback to default style if not found
1 parent dfe187e commit bf5ade2

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/main.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,29 @@ def custom_message_handler(mode, context, message):
4848
else:
4949
print("Warning: Font Awesome Solid font file not found at 'resources/Font Awesome 6 Free-Solid-900.otf'", file=sys.stderr)
5050

51-
# Load the dark theme stylesheet
52-
try:
53-
with open("dark_theme.qss", "r") as f:
54-
style = f.read()
55-
app.setStyleSheet(style)
56-
except FileNotFoundError:
57-
print("Warning: 'dark_theme.qss' not found. Using default style.", file=sys.stderr)
51+
# Load the dark theme stylesheet with proper path resolution
52+
def load_stylesheet(app):
53+
"""Load dark theme stylesheet with proper path resolution."""
54+
qss_paths = [
55+
"dark_theme.qss", # For compiled version
56+
"../dark_theme.qss", # For development (run from src/)
57+
os.path.join(os.path.dirname(__file__), "..", "dark_theme.qss") # Absolute fallback
58+
]
59+
60+
for qss_path in qss_paths:
61+
if os.path.exists(qss_path):
62+
try:
63+
with open(qss_path, "r") as f:
64+
app.setStyleSheet(f.read())
65+
print(f"Loaded dark theme from: {qss_path}")
66+
return True
67+
except Exception as e:
68+
print(f"Failed to load {qss_path}: {e}", file=sys.stderr)
69+
70+
print("Warning: 'dark_theme.qss' not found in any expected location. Using default style.", file=sys.stderr)
71+
return False
72+
73+
load_stylesheet(app)
5874

5975
# Create and show the main window
6076
window = NodeEditorWindow()

0 commit comments

Comments
 (0)