Re-direct help() output to console

Keeps a copy of stdin as well, so that re-assigning this in the python
window does't close the output

Fixes https://gitlab.com/kicad/code/kicad/issues/8047
This commit is contained in:
Seth Hillbrand 2021-07-12 16:20:45 -07:00
parent 8d65663566
commit 76a6177eb7
1 changed files with 9 additions and 0 deletions

View File

@ -907,9 +907,17 @@ class KiCadEditorFrame(KiCadPyFrame):
class KiCadEditorNotebookFrame(KiCadEditorFrame):
def __init__(self, parent):
"""Create EditorNotebookFrame instance."""
self.notebook = None
KiCadEditorFrame.__init__(self, parent)
if self.notebook:
"""Keep pydoc output on stdout instead of pager and
place the stdout into the editor window """
import pydoc, sys
self._keep_stdin = sys.stdin
pydoc.pager = pydoc.plainpager
dispatcher.connect(receiver=self._editorChange,
signal='EditorChange', sender=self.notebook)
@ -935,6 +943,7 @@ class KiCadEditorNotebookFrame(KiCadEditorFrame):
self.setEditor(self.crust.editor)
self.crust.editor.SetFocus()
def _editorChange(self, editor):
"""Editor change signal receiver."""
if not self: