From 8544dd11443c493b7482567d98799164ab7f67ad Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Wed, 11 Oct 2023 10:29:15 +0200 Subject: [PATCH] doc: Disactive documentation display in Pamhyr2 for lighter packages. --- requirements.txt | 2 +- src/View/MainWindow.py | 49 ++++++++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/requirements.txt b/requirements.txt index 01d9a29a..2f9bcc4a 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 8539af1d..cf7e08a7 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}") -- GitLab