Skip to content

docs_view

frog.gui.docs_view ¤

Code for FROG's documentation viewer window.

Classes¤

DocsViewer(parent) ¤

Bases: QAction

A window for viewing documentation.

Create a menu item for opening documentation in a new window.

Parameters:

Name Type Description Default
parent QObject

the menu on which to place the menu item

required
Source code in frog/gui/docs_view.py
15
16
17
18
19
20
21
22
def __init__(self, parent: QObject) -> None:
    """Create a menu item for opening documentation in a new window.

    Args:
        parent: the menu on which to place the menu item
    """
    super().__init__("Open user guide", parent)
    self.triggered.connect(self.show_docs)
Functions¤
create_docs_window() ¤

Create a new window displaying the documentation.

Returns:

Type Description
QMainWindow

A main window showing the html documentation.

Source code in frog/gui/docs_view.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def create_docs_window(self) -> QMainWindow:
    """Create a new window displaying the documentation.

    Returns:
        A main window showing the html documentation.
    """
    docs_window = QMainWindow()
    docs_window.setWindowTitle("User Guide")

    toolbar = QToolBar()
    toolbar.setMovable(False)
    home_btn = toolbar.addAction("Home")
    back_btn = toolbar.addAction("Back")
    forward_btn = toolbar.addAction("Forward")
    docs_window.addToolBar(toolbar)

    docs_path = resources.files("docs")
    self.docs_home = Path(str(docs_path.joinpath("user_guide.html")))
    if not self.docs_home.exists():
        self.docs_home = Path(str(docs_path.joinpath("fallback.html")))
    self.browser = QWebEngineView()
    self._open_homepage()
    home_btn.triggered.connect(self._open_homepage)
    back_btn.triggered.connect(self.browser.back)
    forward_btn.triggered.connect(self.browser.forward)

    layout = QVBoxLayout()
    layout.addWidget(self.browser)

    central = QWidget()
    central.setLayout(layout)

    docs_window.setCentralWidget(central)

    return docs_window
show_docs() ¤

Create the documentation in a new window.

Source code in frog/gui/docs_view.py
24
25
26
27
def show_docs(self) -> None:
    """Create the documentation in a new window."""
    self.docs_window = self.create_docs_window()
    self.docs_window.show()