def createHelpWindow(self): # http://www.walletfox.com/course/qhelpengineexample.php help_path = (Path(__file__).parent / 'TimeView.qhc').resolve() assert help_path.exists() help_engine = QtHelp.QHelpEngine(str(help_path)) help_engine.setupData() tab_widget = QtWidgets.QTabWidget() tab_widget.setMaximumWidth(400) tab_widget.addTab(help_engine.contentWidget(), "Contents") tab_widget.addTab(help_engine.indexWidget(), "Index") text_viewer = HelpBrowser(help_engine) url = "qthelp://org.sphinx.timeview.1.0/doc/index.html" text_viewer.setSource(QtCore.QUrl(url)) help_engine.contentWidget()\ .linkActivated['QUrl'].connect(text_viewer.setSource) help_engine.indexWidget()\ .linkActivated['QUrl', str].connect(text_viewer.setSource) horiz_splitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal) horiz_splitter.insertWidget(0, tab_widget) horiz_splitter.insertWidget(1, text_viewer) help_window = QtWidgets.QDockWidget('Help', self) help_window.setWidget(horiz_splitter) help_window.hide() self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, help_window) return help_window
def createHelpWindow(self): self.helpEngine = QtHelp.QHelpEngine( os.path.join(CURRENT_DIR, "documentation", "qgraphicshelpexample.qhc") ) self.helpEngine.setupData() tWidget = QtWidgets.QTabWidget() tWidget.setMaximumWidth(200) tWidget.addTab(self.helpEngine.contentWidget(), "Contents") tWidget.addTab(self.helpEngine.indexWidget(), "Index") textViewer = HelpBrowser(self.helpEngine) textViewer.setSource( QtCore.QUrl("qthelp://walletfox.qt.helpexample/doc/index.html") ) self.helpEngine.setUsesFilterEngine(True) self.helpEngine.contentWidget().linkActivated.connect(textViewer.setSource) self.helpEngine.indexWidget().linkActivated.connect(textViewer.setSource) horizSplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal) horizSplitter.insertWidget(0, tWidget) horizSplitter.insertWidget(1, textViewer) horizSplitter.hide() self.helpWindow = QtWidgets.QDockWidget(self.tr("Help"), self) self.helpWindow.setWidget(horizSplitter) self.helpWindow.hide() self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.helpWindow)
def __init__(self, qhcfile, *args, **kw): self._kwmap = dict() if not isfile(qhcfile): raise IOError("%s file not found" % (qhcfile)) super(AtAssistant, self).__init__(*args, **kw) loadUI(join(dirname(__file__), "assistant.ui"), self) self.toolBar.setObjectName('Navigation Toolbar') self.hengine = QtHelp.QHelpEngine(qhcfile) self.hengine.setupData() self.hengine.registerDocumentation(qhcfile.replace('.qhc', '.qch')) self.hengine.searchEngine().reindexDocumentation() self.hbrowser = AtHelpBrowser() self.hbrowser.setHelpEngine(self.hengine) self.setupToolBar() self.setCentralWidget(self.hbrowser) self.hengine.contentWidget().linkActivated.connect( self.hbrowser.setSource) self.queries = self.hengine.searchEngine().queryWidget() self.results = self.hengine.searchEngine().resultWidget() self.index = self.hengine.indexWidget() self.contents = self.hengine.contentWidget() self.tabifyDockWidget(self.contentDock, self.indexDock) self.tabifyDockWidget(self.contentDock, self.searchDock) self.searchDock.hide() # search dock (hidden) search = QtWidgets.QFrame(self) vbox = QtWidgets.QVBoxLayout(search) vbox.setContentsMargins(3, 3, 3, 3) vbox.addWidget(self.queries) vbox.addWidget(self.results) self.results.requestShowLink.connect(self.hbrowser.setSource) self.index.linkActivated.connect(self.hbrowser.setSource) self.queries.search.connect(self.search) # index dock index = QtWidgets.QFrame(self) filterEdit = AtLineEdit(self) vbox = QtWidgets.QVBoxLayout(index) vbox.setContentsMargins(3, 3, 3, 3) vbox.addWidget(QtWidgets.QLabel("Look for:")) vbox.addWidget(filterEdit) vbox.addWidget(self.index) filterEdit.textChanged.connect(self.filter) self.searchDock.setWidget(search) self.contentDock.setWidget(self.contents) self.indexDock.setWidget(index) self._restoreSettings() self.indexDock.show() self.contentDock.show() self._genKeywordMap()
def __init__ (self, parent=None): QtWidgets.QDialog.__init__(self, parent) self.engine = QtHelp.QHelpEngine(getdata.path('fgmk.qhc'), self) self.engine.setupData() self.engine.registerDocumentation(getdata.path('fgmk.qch')) self.engine.searchEngine().reindexDocumentation() self.querySearch = self.engine.searchEngine().queryWidget() self.resultSearch = self.engine.searchEngine().resultWidget() splitter = QtWidgets.QSplitter(orientation=QtCore.Qt.Horizontal) self.browser = HelpBrowser(self.engine, self) tWidget = QtWidgets.QTabWidget(self); searcWidget = QtWidgets.QWidget(self) VBox = QtWidgets.QVBoxLayout(searcWidget) VBox.addWidget(self.querySearch) VBox.addWidget(self.resultSearch) tWidget.setMaximumWidth(200); self.hcontent = self.engine.contentWidget() self.hindex = self.engine.indexWidget() tWidget.addTab(self.hcontent, "Contents") #tWidget.addTab(self.hindex, "Index"); tWidget.addTab(searcWidget, "Search") self.hcontent.expandToDepth(2) self.hcontent.setExpandsOnDoubleClick(False) self.hcontent.linkActivated.connect(self.browser.setSource) self.hindex.linkActivated.connect(self.browser.setSource) self.resultSearch.requestShowLink.connect(self.browser.setSource) self.querySearch.search.connect(self.search) splitter.addWidget(tWidget) splitter.addWidget(self.browser) splitter.setSizes((160,440)) hlayout = QtWidgets.QHBoxLayout(self) hlayout.addWidget(splitter) self.browser.setSource(QtCore.QUrl('qthelp://org.sphinx.fgmk.'+ __version__ +'/doc/index.html')) #self.setLayout(hlayout) self.resize(800, 600) self.setWindowTitle(u'%s help' % __title__)