mirror of
https://github.com/RolandWH/SIPPCompare.git
synced 2025-06-28 07:11:16 +01:00
make code compatible with PyInstaller
This commit is contained in:
@ -3,6 +3,7 @@ from PyQt6.QtWidgets import QMainWindow, QWidget
|
||||
from PyQt6 import uic
|
||||
|
||||
import output_window
|
||||
import resource_finder
|
||||
|
||||
|
||||
class SIPPCompare(QMainWindow):
|
||||
@ -10,7 +11,7 @@ class SIPPCompare(QMainWindow):
|
||||
def __init__(self, plat_edit_win: QWidget):
|
||||
super().__init__()
|
||||
# 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
|
||||
# Inputs
|
||||
|
@ -4,12 +4,14 @@ from PyQt6 import uic
|
||||
import datetime
|
||||
import os
|
||||
|
||||
import resource_finder
|
||||
|
||||
|
||||
class OutputWindow(QWidget):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
# 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
|
||||
self.results_str = ""
|
||||
|
@ -5,13 +5,14 @@ from PyQt6 import uic
|
||||
|
||||
from widgets.fastedit_spinbox import FastEditQDoubleSpinBox
|
||||
import main_window
|
||||
import resource_finder
|
||||
|
||||
|
||||
class PlatformEdit(QWidget):
|
||||
def __init__(self, autofill: bool):
|
||||
super().__init__()
|
||||
# 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
|
||||
# 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)
|
Reference in New Issue
Block a user