Skip to content

Commit ad519e9

Browse files
committed
Self-Contained Update
1 parent 36aa0bc commit ad519e9

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
pip install requests
2323
pip install pyside6
2424
- name: Build macOS executable
25-
run: pyinstaller --onefile --noconsole PyCalc-GUI.py
25+
run: pyinstaller -F --add-data "Inter.ttf;." --add-data "icomoon.ttf;." --add-data "PyCalc-GUIico;." PyCalc-GUI.py --noconsole
2626
- name: Upload macOS artifact
2727
uses: actions/upload-artifact@v4
2828
with:
@@ -44,7 +44,7 @@ jobs:
4444
pip install requests
4545
pip install pyside6
4646
- name: Build Linux executable
47-
run: pyinstaller --onefile --noconsole PyCalc-GUI.py
47+
run: pyinstaller -F --add-data "Inter.ttf;." --add-data "icomoon.ttf;." --add-data "PyCalc-GUIico;." PyCalc-GUI.py --noconsole
4848
- name: Upload Linux artifact
4949
uses: actions/upload-artifact@v4
5050
with:

PyCalc-GUI.iss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "PyCalc-GUI"
5-
#define MyAppVersion "1.1"
5+
#define MyAppVersion "1.3"
66
#define MyAppPublisher "Chill-Astro"
77
#define MyAppURL "https://github.com/Chill-Astro/PyCalc-GUI"
88
#define MyAppExeName "PyCalc-GUI.exe"
@@ -78,7 +78,7 @@ Name: "ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"
7878
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
7979

8080
[Files]
81-
Source: "C:\Users\Master\Chill-Astro\PyCalc-GUI\dist\*"; DestDir: "{app}"; Flags: ignoreversion
81+
Source: "C:\Users\Master\Chill-Astro\PyCalc-GUI\dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
8282
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
8383

8484
[Registry]

PyCalc-GUI.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,27 @@
99
from PySide6.QtCore import Qt, QSettings
1010
from PySide6.QtGui import QIcon, QFontDatabase, QFont
1111

12+
# Helper for bundled resources (PyInstaller)
13+
def resource_path(relative_path):
14+
""" Get absolute path to resource, works for dev and for PyInstaller """
15+
if hasattr(sys, '_MEIPASS'):
16+
return os.path.join(sys._MEIPASS, relative_path)
17+
return os.path.join(os.path.abspath(os.path.dirname(__file__)), relative_path)
18+
1219
UPDATE_VERSION_URL = "https://gist.githubusercontent.com/Chill-Astro/738d8c4978d0a71a028235c375a30d1f/raw/2e23a1b0ccb7bdbaa63c0dd128ddbfdb27ef814e/PyC_GUI_V.txt" # Gist URL
1320

1421
class Calculator(QWidget):
1522
def __init__(self):
1623
super().__init__()
17-
self.CURRENT_VERSION = "1.1" # Massive Rewrite
24+
self.CURRENT_VERSION = "1.2" # Self-Contained Update
1825
self.setWindowTitle("PyCalc - GUI")
1926
self.setMinimumSize(400, 500)
20-
icon_path = os.path.join(".", "Pycalc-GUI.ico")
27+
# Set window icon using resource_path (bundled with exe)
28+
icon_path = resource_path("PyCalc-GUI.ico")
2129
if os.path.exists(icon_path):
2230
self.setWindowIcon(QIcon(icon_path))
23-
# Load custom font Inter.ttf
24-
font_id = QFontDatabase.addApplicationFont("Inter.ttf")
31+
# Load custom font Inter.ttf (bundled)
32+
font_id = QFontDatabase.addApplicationFont(resource_path("Inter.ttf"))
2533
font_families = QFontDatabase.applicationFontFamilies(font_id)
2634
if font_families:
2735
custom_font = QFont(font_families[0], 14)
@@ -172,8 +180,8 @@ def initSidebarUI(self):
172180
sidebar_layout.setContentsMargins(2, 8, 2, 8)
173181
# Sidebar buttons (icon only)
174182
self.sidebar_buttons = []
175-
# Try to load icomoon.ttf
176-
icomoon_font_id = QFontDatabase.addApplicationFont("icomoon.ttf")
183+
# Try to load icomoon.ttf (bundled)
184+
icomoon_font_id = QFontDatabase.addApplicationFont(resource_path("icomoon.ttf"))
177185
icomoon_families = QFontDatabase.applicationFontFamilies(icomoon_font_id)
178186
use_icomoon = bool(icomoon_families)
179187
if use_icomoon:

PyCalc-GUI.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ a = Analysis(
55
['PyCalc-GUI.py'],
66
pathex=[],
77
binaries=[],
8-
datas=[],
8+
datas=[('Inter.ttf', '.'), ('icomoon.ttf', '.'), ('PyCalc-GUI.ico', '.')],
99
hiddenimports=[],
1010
hookspath=[],
1111
hooksconfig={},

Readme.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
To export using Pyinstaller,
22

3-
pyinstaller -F -i PyCalc-GUI.ico PyCalc-GUI.py --noconsole
3+
pyinstaller -F -i PyCalc-GUI.ico --add-data "Inter.ttf;." --add-data "icomoon.ttf;." --add-data "PyCalc-GUIico;." PyCalc-GUI.py --noconsole
44

55
[ If without icon ]
66

7-
pyinstaller -F PyCalc-GUI.py --noconsole
7+
pyinstaller -F --add-data "Inter.ttf;." --add-data "icomoon.ttf;." --add-data "PyCalc-GUIico;." PyCalc-GUI.py --noconsole
88

99
If Pyinstaller not available,
1010

0 commit comments

Comments
 (0)