diff --git a/View/mainwindow.py b/View/mainwindow.py index d2c4b4a..dcdfc4f 100644 --- a/View/mainwindow.py +++ b/View/mainwindow.py @@ -39,7 +39,7 @@ from View.about_window import AboutWindow import settings as stg import numpy as np -from subprocess import check_call, run +from subprocess import Popen import time @@ -275,24 +275,36 @@ class Ui_MainWindow(object): cc_kt.exec() def db_browser_for_sqlite(self): - check_call("/usr/bin/sqlitebrowser") + Popen(f"sqlitebrowser", shell=True) def about_window(self): print("about") aw = AboutWindow() aw.exec() + def current_file_path(self, filename): + return os.path.abspath( + os.path.join( + os.path.dirname(__file__), + "..", filename + ) + ) + + def open_doc_file(self, filename): + QtGui.QDesktopServices.openUrl( + QtCore.QUrl( + f"file://{self.current_file_path(filename)}" + ) + ) + def user_manual(self): - open('AcouSed_UserManual.pdf') - run(["open", 'AcouSed_UserManual.pdf']) + self.open_doc_file('AcouSed_UserManual.pdf') def inversion_acoustic_theory(self): - open('Acoustic_Inversion_theory.pdf') - run(["open", 'Acoustic_Inversion_theory.pdf']) + self.open_doc_file('Acoustic_Inversion_theory.pdf') def tutorial_AQUAscat_software(self): - open('Tutorial_AQUAscat_software.pdf') - run(["open", 'Tutorial_AQUAscat_software.pdf']) + self.open_doc_file('Tutorial_AQUAscat_software.pdf') def export_table_of_acoustic_BS_values_to_excel_or_libreOfficeCalc_file(self): diff --git a/main.py b/main.py index 0972456..9d45c0d 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ import sys +import logging import traceback from PyQt5.QtWidgets import QApplication, QMainWindow @@ -26,6 +27,13 @@ import matplotlib.pyplot as plt PERCENT_SCREEN_SIZE = 0.85 _translate = QCoreApplication.translate +logging.basicConfig( + level=logging.DEBUG, + format=('[AcouSed][%(levelname)s] %(message)s') +) + +logger = logging.getLogger() +logger.setLevel(logging.INFO) class MainApplication(QMainWindow): @@ -90,6 +98,9 @@ class MainApplication(QMainWindow): # ---------------- Text File Error ----------------- except Exception as e: + logger.error(str(e)) + logger.error(traceback.format_exc()) + with open("Error_file.txt", "w", encoding="utf-8") as sortie: sortie.write(str(e)) sortie.write(traceback.format_exc()) diff --git a/manifest.scm b/manifest.scm index 3f7d914..5d35665 100644 --- a/manifest.scm +++ b/manifest.scm @@ -210,4 +210,4 @@ user-defined extensions).") "python-scipy" "python-scikit-learn" "python-pyqt@5" "python-pyqt5-sip" "python-numpy@1" "python-pandas@1.5" - "python-matplotlib")))) + "python-matplotlib" "python-odfpy")))) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..10a565e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,13 @@ +matplotlib==3.6.3 +numpy==1.23.5 +pandas==1.5.3 +PyQt5==5.15.9 +PyQt5-Qt5==5.15.2 +PyQt5-sip==12.11.0 +python-dateutil==2.8.2 +scikit-learn==1.2.1 +scipy==1.10.0 +pyqt-file-list-widget==0.0.1 +qtrangeslider==0.1.5 +astropy==6.1.7 +odfpy==1.4.1