class_docstr: Widget displaying console output and accepting command input.
  Implements:
      
    - eval python expressions / exec python statements
    - storable history of commands
    - exception handling allowing commands to be interpreted in the context of any level in the exception stack frame
  
  Why not just use python in an interactive shell (or ipython) ? There are a few reasons:
     
    - pyside does not yet allow Qt event processing and interactive shell at the same time
    - on some systems, typing in the console _blocks_ the qt event loop until the user presses enter. This can
      be baffling and frustrating to users since it would appear the program has frozen.
    - some terminals (eg windows cmd.exe) have notoriously unfriendly interfaces
    - ability to add extra features like exception stack introspection
    - ability to have multiple interactive prompts, including for spawned sub-processes
class_docstr_tok: ["Widget","displaying","console","output","and","accepting","command","input",".","Implements",":","-","eval","python","expressions","\/","exec","python","statements","-","storable","history","of","commands","-","exception","handling","allowing","commands","to","be","interpreted","in","the","context","of","any","level","in","the","exception","stack","frame","Why","not","just","use","python","in","an","interactive","shell","(","or","ipython",")","?","There","are","a","few","reasons",":","-","pyside","does","not","yet","allow","Qt","event","processing","and","interactive","shell","at","the","same","time","-","on","some","systems",",","typing","in","the","console","_blocks_","the","qt","event","loop","until","the","user","presses","enter",".","This","can","be","baffling","and","frustrating","to","users","since","it","would","appear","the","program","has","frozen",".","-","some","terminals","(","eg","windows","cmd.exe",")","have","notoriously","unfriendly","interfaces","-","ability","to","add","extra","features","like","exception","stack","introspection","-","ability","to","have","multiple","interactive","prompts",",","including","for","spawned","sub-processes"]
docstr: ==============  =============================================================================
  **Arguments:**
  namespace       dictionary containing the initial variables present in the default namespace
  historyFile     optional file for storing command history
  text            initial text to display in the console window
  editor          optional string for invoking code editor (called when stack trace entries are 
                  double-clicked). May contain {fileName} and {lineNum} format keys. Example:: 
                
                      editorCommand --loadfile {fileName} --gotoline {lineNum}
  ==============  =============================================================================
docstr_tok: ["==============","=============================================================================","*","*","Arguments",":","*","*","namespace","dictionary","containing","the","initial","variables","present","in","the","default","namespace","historyFile","optional","file","for","storing","command","history","text","initial","text","to","display","in","the","console","window","editor","optional","string","for","invoking","code","editor","(","called","when","stack","trace","entries","are","double-clicked",")",".","May","contain","{","fileName","}","and","{","lineNum","}","format","keys",".","Example",":",":","editorCommand","--","loadfile","{","fileName","}","--","gotoline","{","lineNum","}","==============","============================================================================="]
code: def __init__(
      self,
      parent=None,
      namespace=None,
      historyFile=None,
      text=None,
      editor=None,
  ):
      """
      ==============  =============================================================================
      **Arguments:**
      namespace       dictionary containing the initial variables present in the default namespace
      historyFile     optional file for storing command history
      text            initial text to display in the console window
      editor          optional string for invoking code editor (called when stack trace entries are
                      double-clicked). May contain {fileName} and {lineNum} format keys. Example::
  
                          editorCommand --loadfile {fileName} --gotoline {lineNum}
      ==============  =============================================================================
      """
      QtWidgets.QWidget.__init__(self, parent)
  
      self._setupUi()
  
      if namespace is None:
          namespace = {}
      namespace["__console__"] = self
  
      self.localNamespace = namespace
      self.editor = editor
  
      self.output = self.repl.output
      self.input = self.repl.input
      self.input.setFocus()
  
      if text is not None:
          self.output.setPlainText(text)
  
      self.historyFile = historyFile
  
      try:
          history = self.loadHistory()
      except Exception as exc:
          sys.excepthook(*sys.exc_info())
          history = None
      if history is not None:
          self.input.history = [""] + history
          self.historyList.addItems(history[::-1])
  
      self.currentTraceback = None
  
imports: import os
  import sys
  import pickle
  import subprocess
  from ..None import getConfigOption
  from ..Qt import QtCore, QtWidgets
  from .repl_widget import ReplWidget
  from .exception_widget import ExceptionHandlerWidget
label_desc: Use image node_id 1 to create a new ConsoleWidget object from inherited base classes: QtWidgets with example: obj = ConsoleWidget(parent, namespace, historyFile, text, editor)