Skip to content

Commit

Permalink
Use cx_freeze instead of pyinstaller for executable
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne authored and Flora committed Jun 28, 2024
1 parent c296a55 commit 4fbcdd9
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
build/
build/BigPictureTV
44 changes: 0 additions & 44 deletions BigPictureTV.spec

This file was deleted.

12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ This Python project automates switching between a monitor and a TV when launchin

![image](screenshots/help_dialog.png)

⚠️ Exe built with pyinstaller. Windows defender may flag it. Either add an exception or do not use it. ⚠️

## Download

Head to [release](https://github.com/Odizinne/BigPictureTV/releases) section and grab the latest one.

if you're feeling adventurous you can download the latest main build [here](https://raw.githubusercontent.com/Odizinne/BigPictureTV/main/dist/BigPictureTV.exe)<br/>
if you're feeling adventurous you can download the latest main build [here](https://raw.githubusercontent.com/Odizinne/BigPictureTV/main/build/BigPictureTV.zip)<br/>
Main build is updated often, but may contain bugs.
## Requirements

Expand All @@ -24,19 +22,17 @@ Main build is updated often, but may contain bugs.
- PyQt5 (Ui)
- winshell (Startup shortcut manipulation)
- pygetwindow (Big Picture window detection)
- pyinstaller (Standalone exe creation)
- cx_freeze (Standalone exe creation)

`pip install pyqt5 winshell pygetwindow pyinstaller`
`pip install pyqt5 winshell pygetwindow cx_freeze`

## Build

Make sure you installed required dependencies.<br/>

- Clone this repository `git clone [email protected]:Odizinne/BigPictureTV.git`.<br/>
- Move inside the directory `cd BigPictureTV`.<br/>
- Build the executable `pyinstaller BigPictureTV.spec`.

Since we're building with `console=False`, windows defender may not like it. You'll need to authorize the file.
- Build the executable `python setup_cxfreeze.py build`.

## Todo

Expand Down
Binary file modified screenshots/help_dialog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/settings_window.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions setup_cxfreeze.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from cx_Freeze import setup, Executable

setup(
name='BigPictureTV',
version='1.0',
description='BigPictureTV application',
executables=[
Executable('src/BigPictureTV.py', base='Win32GUI', icon='src/icons/steamos-logo.ico', target_name='BigPictureTV')
],
options={
'build_exe': {
'include_files': [
('src/ui/design.ui', 'ui/design.ui'),
('src/ui/help.ui', 'ui/help.ui'),
('src/ui/style.qss', 'ui/style.qss'),
('src/icons/steamos-logo.png', 'icons/steamos-logo.png')
],
'excludes': [],
'optimize': 0,
'build_exe': 'build/BigPictureTV',
}
}
)
13 changes: 10 additions & 3 deletions src/BigPictureTV.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,18 @@ class Mode(Enum):
DESKTOP = 1
GAMEMODE = 2

if getattr(sys, 'frozen', False):
ICONS_FOLDER = 'icons'
UI_FOLDER = 'ui'
print("Running in frozen mode (cx_Freeze)")
else:
UI_FOLDER = os.path.join(os.path.dirname(__file__), 'ui')
ICONS_FOLDER = os.path.join(os.path.dirname(__file__), 'icons')
print("Running in normal Python mode")

GAMEMODE_SCREEN = "/external"
DESKTOP_SCREEN = "/internal"
SETTINGS_FILE = os.path.join(os.environ['APPDATA'], "BigPictureTV", "settings.json")
UI_FOLDER = os.path.join(os.path.dirname(__file__), 'ui')
ICONS_FOLDER = os.path.join(os.path.dirname(__file__), 'icons')

tray_icon = None
current_mode = None
Expand Down Expand Up @@ -357,7 +364,7 @@ def __init__(self, stylesheet=None):
current_mode = read_current_mode()
constants = load_constants()

style_file = os.path.join(os.path.dirname(__file__), UI_FOLDER, 'style.qss')
style_file = os.path.join(os.path.join(UI_FOLDER, 'style.qss'))
if os.path.exists(style_file):
with open(style_file, 'r') as f:
app.setStyleSheet(f.read())
Expand Down
Binary file added src/icons/steamos-logo.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion src/ui/help.ui
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;In millisecond.&lt;br /&gt;Define how many time bigPictureTV should check for big picture window presence.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;In millisecond.&lt;br /&gt;Define how many time BigPictureTV should check for big picture window presence.&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Going under 100 ms is not recommended.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
Expand Down

0 comments on commit 4fbcdd9

Please sign in to comment.