Add support for PyInstaller bundle in main_window.py
- Updated icon path handling to support both development mode and PyInstaller bundle. - Modified script path loading to accommodate PyInstaller bundle structure. - Adjusted download interceptor path to work with PyInstaller bundle.
This commit is contained in:
parent
d799339d93
commit
0c276b9022
3 changed files with 2912 additions and 2877 deletions
|
|
@ -4,6 +4,7 @@ import asyncio
|
|||
import json
|
||||
import logging
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
|
@ -280,7 +281,14 @@ class MainWindow(QMainWindow):
|
|||
)
|
||||
|
||||
# Set window icon
|
||||
icon_path = Path(__file__).parent.parent.parent.parent / "resources" / "icons" / "app.ico"
|
||||
# Support both development mode and PyInstaller bundle
|
||||
if hasattr(sys, '_MEIPASS'):
|
||||
# Running as PyInstaller bundle
|
||||
icon_path = Path(sys._MEIPASS) / "resources" / "icons" / "app.ico" # type: ignore
|
||||
else:
|
||||
# Running in development mode
|
||||
icon_path = Path(__file__).parent.parent.parent.parent / "resources" / "icons" / "app.ico"
|
||||
|
||||
if icon_path.exists():
|
||||
self.setWindowIcon(QIcon(str(icon_path)))
|
||||
logger.debug(f"Window icon set from {icon_path}")
|
||||
|
|
@ -441,13 +449,24 @@ class MainWindow(QMainWindow):
|
|||
|
||||
# Load bridge script from file
|
||||
# Using intercept script - prevents browser drag, hands off to Qt
|
||||
script_path = Path(__file__).parent / "bridge_script_intercept.js"
|
||||
# Support both development mode and PyInstaller bundle
|
||||
if hasattr(sys, '_MEIPASS'):
|
||||
# Running as PyInstaller bundle
|
||||
script_path = Path(sys._MEIPASS) / "webdrop_bridge" / "ui" / "bridge_script_intercept.js" # type: ignore
|
||||
else:
|
||||
# Running in development mode
|
||||
script_path = Path(__file__).parent / "bridge_script_intercept.js"
|
||||
|
||||
try:
|
||||
with open(script_path, 'r', encoding='utf-8') as f:
|
||||
bridge_code = f.read()
|
||||
|
||||
# Load download interceptor
|
||||
download_interceptor_path = Path(__file__).parent / "download_interceptor.js"
|
||||
if hasattr(sys, '_MEIPASS'):
|
||||
download_interceptor_path = Path(sys._MEIPASS) / "webdrop_bridge" / "ui" / "download_interceptor.js" # type: ignore
|
||||
else:
|
||||
download_interceptor_path = Path(__file__).parent / "download_interceptor.js"
|
||||
|
||||
download_interceptor_code = ""
|
||||
try:
|
||||
with open(download_interceptor_path, 'r', encoding='utf-8') as f:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue