diff --git a/bigpicture-external.py b/bigpicture-external.py index e2c945f..a9ee618 100644 --- a/bigpicture-external.py +++ b/bigpicture-external.py @@ -52,10 +52,8 @@ def create_default_settings(constants_path): with open(constants_path, 'w') as f: json.dump(settings_template, f, indent=4) - app = QApplication(sys.argv) - window = SettingsWindow() - window.show() - app.exec_() + # Function to open settings window + open_settings_window() def read_stream_status(): file_path = os.path.join(os.environ['APPDATA'], "sunshine-status", "status.txt") @@ -134,7 +132,7 @@ def is_bigpicture_running(): for window_title in gw.getAllTitles()) def get_mode_file_path(): - script_dir = os.path.dirname(os.path.abspath(__file__)) + script_dir = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__))) return os.path.join(script_dir, 'current_mode.txt') def write_current_mode(current_mode): @@ -195,7 +193,17 @@ class SettingsWindow(QMainWindow): def __init__(self): super().__init__() - uic.loadUi('design.ui', self) + # Determine if the script is bundled or run as a script + if getattr(sys, 'frozen', False): + # Bundled by PyInstaller + basedir = sys._MEIPASS + else: + # Run as a script + basedir = os.path.dirname(__file__) + + self.constants_path = os.path.join(os.environ['APPDATA'], "bigpicture-eternal", 'settings.json') + + uic.loadUi(os.path.join(basedir, 'design.ui'), self) self.constants = load_constants() self.load_settings() @@ -203,6 +211,8 @@ def __init__(self): self.saveButton.clicked.connect(self.save_settings) def load_settings(self): + self.constants = load_constants() + self.steamEntry.setText(' '.join(self.constants['BIG_PICTURE_KEYWORDS'])) self.desktopEntry.setText(self.constants['DESKTOP_AUDIO']) self.gamemodeEntry.setText(self.constants['GAMEMODE_AUDIO']) diff --git a/bigpicture-external.spec b/bigpicture-external.spec new file mode 100644 index 0000000..8e8df1a --- /dev/null +++ b/bigpicture-external.spec @@ -0,0 +1,38 @@ +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['bigpicture-external.py'], + pathex=[], + binaries=[], + datas=[('default_icon.png', '.'), ('design.ui', '.')], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=0, +) +pyz = PYZ(a.pure) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.datas, + [], + name='bigpicture-external', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=False, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +)