Fix application icon not showing in PyInstaller builds
The icon wasn't working in frozen executables because: 1. LocalTranscription.png wasn't being bundled in the PyInstaller build 2. The code was using Path(__file__).parent which doesn't work in frozen exes Changes: - Added LocalTranscription.png to datas in local-transcription.spec - Updated main.py to use sys._MEIPASS for frozen executables - Updated gui/main_window_qt.py to use sys._MEIPASS for frozen executables - Both files now detect if running frozen and adjust icon path accordingly The icon will now appear correctly in: - Window titlebar - Taskbar (Windows) / Dock (macOS) - Alt-Tab switcher 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -101,7 +101,15 @@ class MainWindow(QMainWindow):
|
|||||||
self.resize(900, 700)
|
self.resize(900, 700)
|
||||||
|
|
||||||
# Set application icon
|
# Set application icon
|
||||||
|
# In PyInstaller frozen executables, use _MEIPASS for bundled files
|
||||||
|
import sys
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
# Running in PyInstaller bundle
|
||||||
|
icon_path = Path(sys._MEIPASS) / "LocalTranscription.png"
|
||||||
|
else:
|
||||||
|
# Running in normal Python
|
||||||
icon_path = Path(__file__).parent.parent / "LocalTranscription.png"
|
icon_path = Path(__file__).parent.parent / "LocalTranscription.png"
|
||||||
|
|
||||||
if icon_path.exists():
|
if icon_path.exists():
|
||||||
from PySide6.QtGui import QIcon
|
from PySide6.QtGui import QIcon
|
||||||
self.setWindowIcon(QIcon(str(icon_path)))
|
self.setWindowIcon(QIcon(str(icon_path)))
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ except ImportError:
|
|||||||
binaries = []
|
binaries = []
|
||||||
datas = [
|
datas = [
|
||||||
('config/default_config.yaml', 'config'),
|
('config/default_config.yaml', 'config'),
|
||||||
|
('LocalTranscription.png', '.'), # Include icon for runtime window icon
|
||||||
(vad_assets_path, 'faster_whisper/assets'), # Include VAD model
|
(vad_assets_path, 'faster_whisper/assets'), # Include VAD model
|
||||||
] + pvporcupine_data_files # Include pvporcupine resources
|
] + pvporcupine_data_files # Include pvporcupine resources
|
||||||
hiddenimports = [
|
hiddenimports = [
|
||||||
|
|||||||
7
main.py
7
main.py
@@ -89,7 +89,14 @@ def main():
|
|||||||
app.setOrganizationName("LocalTranscription")
|
app.setOrganizationName("LocalTranscription")
|
||||||
|
|
||||||
# Set application icon
|
# Set application icon
|
||||||
|
# In PyInstaller frozen executables, use _MEIPASS for bundled files
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
# Running in PyInstaller bundle
|
||||||
|
icon_path = Path(sys._MEIPASS) / "LocalTranscription.png"
|
||||||
|
else:
|
||||||
|
# Running in normal Python
|
||||||
icon_path = project_root / "LocalTranscription.png"
|
icon_path = project_root / "LocalTranscription.png"
|
||||||
|
|
||||||
if icon_path.exists():
|
if icon_path.exists():
|
||||||
from PySide6.QtGui import QIcon
|
from PySide6.QtGui import QIcon
|
||||||
app.setWindowIcon(QIcon(str(icon_path)))
|
app.setWindowIcon(QIcon(str(icon_path)))
|
||||||
|
|||||||
Reference in New Issue
Block a user