Skip to content

Commit

Permalink
Allow for relative paths for pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
hydroEng committed Feb 22, 2023
1 parent df671f3 commit 4cb4d5d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
Binary file modified src/assets/screenshot_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 18 additions & 6 deletions src/tuflow_ensemble_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
from PyQt6.QtGui import QPalette, QColor, QFont, QPixmap, QIcon
from PyQt6.QtWidgets import QFrame, QMessageBox, QApplication, QWidget, QFileDialog, QPushButton, QLabel, QVBoxLayout, QHBoxLayout
from PyQt6.QtCore import QObject, QThreadPool, QRunnable, pyqtSignal, pyqtSlot

import os
import sys
import tuflow_ensemble

def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller.
From https://stackoverflow.com/questions/31836104/pyinstaller-and-onefile-how-to-include-an-image-in-the-exe-file"""
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")

return os.path.join(base_path, relative_path)


class WorkerSignals(QObject):

"""
Expand Down Expand Up @@ -41,9 +53,9 @@ def __init__(self):
super().__init__()

self.title = 'TUFLOW Ensemble Tool'
self.iconPath = resource_path("assets/rain-svgrepo-com.svg")

self.setWindowIcon(QIcon(r"assets/rain-svgrepo-com.svg"))
windowIcon = QIcon(r"assets/rain-svgrepo-com.svg")
self.setWindowIcon(QIcon(self.iconPath))

self.left = 10
self.top = 10
Expand All @@ -58,12 +70,12 @@ def initUI(self):

self.setWindowTitle(self.title)
self.setFixedWidth(self.width)
self.setMinimumHeight(340)
self.setMinimumHeight(330)

# Title of app in UI Window

self.title_label = QLabel(self)
self.title_label.setText("TUFLOW Ensemble Tool")
self.title_label.setText("TUFLOW Ensemble Tool v.1.0")

# Set title label formatting

Expand Down Expand Up @@ -91,7 +103,7 @@ def initUI(self):
# Add App Icon

self.app_icon_label = QLabel(self)
self.app_icon = QPixmap(r"assets/rain-svgrepo-com.svg").scaledToWidth(80)
self.app_icon = QPixmap(self.iconPath).scaledToWidth(80)

# Format app icon

Expand Down

0 comments on commit 4cb4d5d

Please sign in to comment.