Paul S
48f8dc221a
added internationalization, clsTableWidget and INI-file settings and pyinstaller-scripts
58 lines
2.2 KiB
Python
58 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
project: GarageCalc1
|
|
file: utils.py
|
|
summary: helper functions
|
|
"""
|
|
|
|
# Standard library imports
|
|
import sys
|
|
import os
|
|
|
|
# Third party imports
|
|
from PySide2.QtWidgets import QMessageBox, QApplication, QMainWindow, QTableWidgetItem, QStatusBar, QAction
|
|
from PySide2 import QtCore
|
|
from PySide2.QtGui import QIcon, QPixmap
|
|
from PySide2.QtCore import QFile, QSize
|
|
from PySide2.QtUiTools import QUiLoader
|
|
|
|
# local globals
|
|
APP_ICON = "./img/icons8-garage-32.ico"
|
|
|
|
def resource_path(relative_path):
|
|
""" Get absolute path to resource, works for dev and for PyInstaller """
|
|
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)
|
|
|
|
def show_about():
|
|
qApp = QApplication.instance()
|
|
msg = QMessageBox()
|
|
msg.setIconPixmap(QPixmap(resource_path(APP_ICON)))
|
|
|
|
APP_NAME = qApp.translate("main", "Garage Space Calculator")
|
|
APP_DESCR = qApp.translate("main", "Calculates available garage space")
|
|
|
|
text = "<p align='center'><h1>" + qApp.applicationDisplayName() + " " + \
|
|
"<br>" + qApp.applicationVersion() + "</h1>" + \
|
|
"<br>" + APP_NAME + "<br>" + \
|
|
"<br>" + APP_DESCR + "<br>" + \
|
|
"<br>" + qApp.translate("utils", "Idea") + ": Balazs Fabian" + "<br>" + \
|
|
"<br>" + qApp.copyright + "<br>" \
|
|
"<br> <a href='" + qApp.website + "'>" + qApp.website + "</a></p>"
|
|
|
|
text = text + "<p align='center'>" + qApp.translate("utils", "Used icons: Theme") + " 'Cute Color' " + qApp.translate("utils", "from") + " <a href='https://icons8.com/'>Icons8</a></p>"
|
|
text = text + "<p align='center'>Python " + qApp.translate("utils", "Version") + ": " + f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro} {sys.version_info.releaselevel}"
|
|
text = text + "<br>" + f"{sys.executable}" + "<br>"
|
|
text = text + "<br>Qt " + qApp.translate("utils", "Version") + ": " + f"{QtCore.__version__}"
|
|
|
|
msg.setText(text)
|
|
msg.setWindowTitle("About")
|
|
msg.setStandardButtons(QMessageBox.Ok)
|
|
|
|
msg.exec_()
|