mirror of
https://github.com/RolandWH/SIPPCompare.git
synced 2025-04-19 16:01:48 +01:00
make code compatible with PyInstaller
This commit is contained in:
parent
cc5686d3d7
commit
ace96dfc3a
9
.gitignore
vendored
9
.gitignore
vendored
@ -1,2 +1,9 @@
|
|||||||
/designer.exe - Shortcut.lnk
|
/designer.exe - Shortcut.lnk
|
||||||
.idea/workspace.xml
|
.idea/workspace.xml
|
||||||
|
.idea/discord.xml
|
||||||
|
.idea/encodings.xml
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
output/
|
||||||
|
src/*/__pycache__/
|
||||||
|
src/__pycache__/
|
44
SIPPCompare.spec
Normal file
44
SIPPCompare.spec
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
# -*- mode: python ; coding: utf-8 -*-
|
||||||
|
|
||||||
|
|
||||||
|
a = Analysis(
|
||||||
|
['src\\main.py'],
|
||||||
|
pathex=[],
|
||||||
|
binaries=[],
|
||||||
|
datas=[('gui/*.ui', 'gui')],
|
||||||
|
hiddenimports=[],
|
||||||
|
hookspath=[],
|
||||||
|
hooksconfig={},
|
||||||
|
runtime_hooks=[],
|
||||||
|
excludes=[],
|
||||||
|
noarchive=False,
|
||||||
|
optimize=0,
|
||||||
|
)
|
||||||
|
pyz = PYZ(a.pure)
|
||||||
|
|
||||||
|
exe = EXE(
|
||||||
|
pyz,
|
||||||
|
a.scripts,
|
||||||
|
[],
|
||||||
|
exclude_binaries=True,
|
||||||
|
name='SIPPCompare',
|
||||||
|
debug=False,
|
||||||
|
bootloader_ignore_signals=False,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
console=False,
|
||||||
|
disable_windowed_traceback=False,
|
||||||
|
argv_emulation=False,
|
||||||
|
target_arch=None,
|
||||||
|
codesign_identity=None,
|
||||||
|
entitlements_file=None,
|
||||||
|
)
|
||||||
|
coll = COLLECT(
|
||||||
|
exe,
|
||||||
|
a.binaries,
|
||||||
|
a.datas,
|
||||||
|
strip=False,
|
||||||
|
upx=True,
|
||||||
|
upx_exclude=[],
|
||||||
|
name='SIPPCompare',
|
||||||
|
)
|
@ -3,6 +3,7 @@ from PyQt6.QtWidgets import QMainWindow, QWidget
|
|||||||
from PyQt6 import uic
|
from PyQt6 import uic
|
||||||
|
|
||||||
import output_window
|
import output_window
|
||||||
|
import resource_finder
|
||||||
|
|
||||||
|
|
||||||
class SIPPCompare(QMainWindow):
|
class SIPPCompare(QMainWindow):
|
||||||
@ -10,7 +11,7 @@ class SIPPCompare(QMainWindow):
|
|||||||
def __init__(self, plat_edit_win: QWidget):
|
def __init__(self, plat_edit_win: QWidget):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
# Import Qt Designer UI XML file
|
# Import Qt Designer UI XML file
|
||||||
uic.loadUi("gui/main_gui.ui", self)
|
uic.loadUi(resource_finder.get_res_path("gui/main_gui.ui"), self)
|
||||||
|
|
||||||
# Initialise class variables
|
# Initialise class variables
|
||||||
# Inputs
|
# Inputs
|
||||||
|
@ -4,12 +4,14 @@ from PyQt6 import uic
|
|||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import resource_finder
|
||||||
|
|
||||||
|
|
||||||
class OutputWindow(QWidget):
|
class OutputWindow(QWidget):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
# Import Qt Designer UI XML file
|
# Import Qt Designer UI XML file
|
||||||
uic.loadUi("gui/output_window.ui", self)
|
uic.loadUi(resource_finder.get_res_path("gui/output_window.ui"), self)
|
||||||
|
|
||||||
# Initialise class variables
|
# Initialise class variables
|
||||||
self.results_str = ""
|
self.results_str = ""
|
||||||
|
@ -5,13 +5,14 @@ from PyQt6 import uic
|
|||||||
|
|
||||||
from widgets.fastedit_spinbox import FastEditQDoubleSpinBox
|
from widgets.fastedit_spinbox import FastEditQDoubleSpinBox
|
||||||
import main_window
|
import main_window
|
||||||
|
import resource_finder
|
||||||
|
|
||||||
|
|
||||||
class PlatformEdit(QWidget):
|
class PlatformEdit(QWidget):
|
||||||
def __init__(self, autofill: bool):
|
def __init__(self, autofill: bool):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
# Import Qt Designer UI XML file
|
# Import Qt Designer UI XML file
|
||||||
uic.loadUi("gui/platform_edit.ui", self)
|
uic.loadUi(resource_finder.get_res_path("gui/platform_edit.ui"), self)
|
||||||
|
|
||||||
# Initialise class variables
|
# Initialise class variables
|
||||||
# Create main window object, passing this instance as param
|
# Create main window object, passing this instance as param
|
||||||
|
13
src/resource_finder.py
Normal file
13
src/resource_finder.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import os.path
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
# If using PyInstaller, use it's temporary path, otherwise use cwd
|
||||||
|
# Credit: https://stackoverflow.com/questions/7674790/bundling-data-files-with-pyinstaller-onefile/13790741#13790741
|
||||||
|
def get_res_path(relative_path):
|
||||||
|
try:
|
||||||
|
base_path = sys._MEIPASS
|
||||||
|
except AttributeError:
|
||||||
|
base_path = os.path.abspath(".")
|
||||||
|
|
||||||
|
return os.path.join(base_path, relative_path)
|
Loading…
x
Reference in New Issue
Block a user