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