Skip to content

Commit

Permalink
fixes for pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne authored and Flora committed Jun 22, 2024
1 parent 81cb887 commit 5d84cb2
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 6 deletions.
22 changes: 16 additions & 6 deletions bigpicture-external.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -195,14 +193,26 @@ 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()

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'])
Expand Down
38 changes: 38 additions & 0 deletions bigpicture-external.spec
Original file line number Diff line number Diff line change
@@ -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,
)

0 comments on commit 5d84cb2

Please sign in to comment.