""" Help pages """ from qtpy.QtCore import Qt, QUrl from qtpy.QtGui import QIcon, QKeySequence from qtpy.QtWidgets import (QAction, QApplication, QDialog, QLabel, QTextBrowser, QToolBar, QVBoxLayout) class HelpBrowser(QDialog): def __init__(self, helpbase, page, parent=None, xlength=600, ylength=550): super(HelpBrowser, self).__init__(parent) self.setAttribute(Qt.WA_DeleteOnClose) self.setAttribute(Qt.WA_GroupLeader) self.xlength = xlength self.ylength = ylength back_action = QAction(QIcon(":/back.png"), "&Back", self) back_action.setShortcut(QKeySequence.Back) home_action = QAction(QIcon(":/home.png"), "&Home", self) home_action.setShortcut("Home") self.page_label = QLabel() tool_bar = QToolBar() tool_bar.addAction(back_action) tool_bar.addAction(home_action) tool_bar.addWidget(self.page_label) self.text_browser = QTextBrowser() layout = QVBoxLayout() layout.addWidget(tool_bar) layout.addWidget(self.text_browser, 1) self.setLayout(layout) back_action.triggered.connect(self.text_browser.backward) home_action.triggered.connect(self.text_browser.home) self.text_browser.sourceChanged.connect(self.update_page_title) self.text_browser.setSearchPaths([":/help", helpbase]) self.text_browser.setSource(QUrl(page)) self.resize(self.xlength, self.ylength) self.setWindowTitle("{0} Help".format(parent.pymodule)) QApplication.processEvents() def update_page_title(self): self.page_label.setText(self.text_browser.documentTitle())