ConsoleWidget¶
-
class
pyqtgraph.console.
ConsoleWidget
(parent=None, namespace=None, historyFile=None, text=None, editor=None)[source]¶ 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
-
catchAllExceptions
(catch=True)[source]¶ If True, the console will catch all unhandled exceptions and display the stack trace. Each exception caught clears the last.
-
catchNextException
(catch=True)[source]¶ If True, the console will catch the next unhandled exception and display the stack trace.
-
setStack
(frame=None, tb=None)[source]¶ Display a call stack and exception traceback.
This allows the user to probe the contents of any frame in the given stack.
frame may either be a Frame instance or None, in which case the current frame is retrieved from
sys._getframe()
.If tb is provided then the frames in the traceback will be appended to the end of the stack list. If tb is None, then sys.exc_info() will be checked instead.