-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicon_fix.py
More file actions
32 lines (28 loc) · 971 Bytes
/
icon_fix.py
File metadata and controls
32 lines (28 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""
Icon Fix Module
Handles application icon loading for PyQt5 bundled executables
"""
import os
import sys
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication
def get_resource_path(relative_path):
"""Get absolute path to resource, works for dev and PyInstaller bundle"""
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
def set_app_icon(app):
"""
Set the application icon for QApplication
Args:
app: QApplication instance
"""
icon_path = get_resource_path('assets/app_icon.ico')
if os.path.exists(icon_path):
app.setWindowIcon(QIcon(icon_path))
print(f"SUCCESS: Application icon loaded from {icon_path}")
else:
print(f"WARNING: Icon file not found at {icon_path}")