diff --git a/requirements.txt b/requirements.txt index 01d9a29a64b132d0b5e03a03c8717d1a82417043..2f9bcc4aeebbed35ef1b113f47c7c74c48eca37d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ PyQt5==5.15.4 PyQt5-Qt5==5.15.2 PyQt5-sip==12.12.2 -PyQtWebEngine==5.15.6 +#PyQtWebEngine==5.15.6 pyqtgraph>=0.12.1 matplotlib>=3.4.1 numpy>=1.24.2 diff --git a/src/View/MainWindow.py b/src/View/MainWindow.py index 8539af1db3e39cf0f8fc65475dcf744e601e1c42..cf7e08a76213e4fab32599431f179639c87da8c9 100644 --- a/src/View/MainWindow.py +++ b/src/View/MainWindow.py @@ -16,7 +16,7 @@ # -*- coding: utf-8 -*- -import os +import os, sys import logging import subprocess from queue import Queue @@ -56,9 +56,17 @@ from View.SolverParameters.Window import SolverParametersWindow from View.RunSolver.Window import SelectSolverWindow, SolverLogWindow from View.CheckList.Window import CheckListWindow from View.Results.Window import ResultsWindow -from View.Doc.Window import DocWindow from View.Debug.Window import ReplWindow +# Optional internal display of documentation for make the application +# package lighter... +try: + from View.Doc.Window import DocWindow + _doc = "internal" +except Exception as e: + print("Handle exception: {e}") + _doc = "external" + from Model.Study import Study logger = logging.getLogger() @@ -132,6 +140,9 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): if self.conf.last_study != "" and not self.conf.close_correctly: self.dialog_reopen_study() + if _doc == "external": + logger.info("doc: Internal documentation is not available...") + def set_title(self): title = "(dbg) " if self.conf.debug else "" @@ -726,16 +737,36 @@ class ApplicationWindow(QMainWindow, ListedSubWindow, WindowToolKit): # DOCUMENTATION # ################# + def _doc_path_file(self, filename): + if ".py" in sys.argv[0]: + return os.path.abspath( + os.path.join( + os.path.dirname(__file__), + "..", "..", "doc", filename + ) + ) + + return os.path.abspath( + os.path.join( + os.path.dirname(__file__), + "..", "..", "..", "doc", filename + ) + ) + def open_doc(self, filename): - if ".odt" in filename: - url = QUrl(f"file://{DocWindow._path_file(filename)}") + if _doc == "external": + url = QUrl(f"file://{self._doc_path_file(filename)}") QDesktopServices.openUrl(url) else: - doc = DocWindow( - filename = filename, - parent = self - ) - doc.show() + if ".odt" in filename: + url = QUrl(f"file://{DocWindow._path_file(filename)}") + QDesktopServices.openUrl(url) + else: + doc = DocWindow( + filename = filename, + parent = self + ) + doc.show() def open_doc_user(self, ext="pdf"): self.open_doc(f"Pamhyr2-users.{ext}")