OpenStructure
helpwidget.py
Go to the documentation of this file.
1 from PyQt5 import QtWidgets
2 from ost import gui
3 class DocWidget(QtWidgets.QWidget):
4  def __init__(self, parent=None):
5  QtWidgets.QWidget.__init__(self, parent)
6  l=QtWidgets.QVBoxLayout(self)
7  l.setContentsMargins(0,0,0,0)
8  self.setWindowTitle('OpenStructure Help')
9  self.searchboxsearchbox=QtWidgets.QLineEdit(self)
10  l.addWidget(self.searchboxsearchbox)
11  self.doctextdoctext=QtWidgets.QTextEdit('', self)
12  l.addWidget(self.doctextdoctext)
13  self.setLayout(l)
14  self.searchboxsearchbox.returnPressed.connect(self.OnReturnPressedOnReturnPressed)
15  def OnReturnPressed(self):
16  help(str(self.searchboxsearchbox.text()))
17 doc_widget=DocWidget()
18 doc_widget_for_panel=gui.Widget(doc_widget)
19 panels=gui.GostyApp.Instance().perspective.panels
20 panels.AddWidgetToPool("OpenStructure Help",doc_widget_for_panel)
21 
22 
23 class Help:
24  def __call__(self, what=None):
25  import pydoc
26  d=pydoc.HTMLDoc()
27  if what==None:
28  doc_widget.doctext.setHtml('')
29  doc_widget.searchbox.setText('')
30  else:
31  try:
32  s=d.document(pydoc.resolve(what)[0])
33  except ImportError as detail:
34  s=str(detail)
35  doc_widget.doctext.setHtml(s)
36  doc_widget.searchbox.setText('')
37  if not doc_widget.isVisible():
38  panels.AddWidget(gui.PanelPosition.RIGHT_PANEL, doc_widget_for_panel, False)
39  def __repr__(self):
40  return 'Type help() for interactive help, or help(object) for help about object.'
41 
42 help=Help()
Base class for widgets.
Definition: widget.hh:40
def __init__(self, parent=None)
Definition: helpwidget.py:4
def __call__(self, what=None)
Definition: helpwidget.py:24