Widget for a Python shell.
More...
#include <pqPythonShell.h>
Inherits QWidget.
|
| void | executing (bool starting) |
| | signal fired whenever the shell starts (starting=true) and finishes (starting=false) executing a Python command/script. More...
|
| |
Widget for a Python shell.
pqPythonShell is a QWidget subclass that provides an interactive Python shell. It uses vtkPythonInteractiveInterpreter to provide an interactive Python interpreter. Note that this is still executing Python code using the application wide global Python interpreter, it just keeps the context separate using an instance of core.InteractiveConsole internally.
Python initialization
pqPythonShell does not initialize Python on creation. By default, it waits till the pqConsoleWidget gets focus or pqPythonShell::executeScript is called. One can also call pqPythonShell::initialize explicitly to initialize the interpreter.
- See also
- pqConsoleWidget.
Definition at line 33 of file pqPythonShell.h.
◆ PrintMode
◆ pqPythonShell()
| pqPythonShell::pqPythonShell |
( |
QWidget * |
parent = nullptr, |
|
|
Qt::WindowFlags |
flags = Qt::WindowFlags{} |
|
) |
| |
◆ ~pqPythonShell()
| pqPythonShell::~pqPythonShell |
( |
| ) |
|
|
override |
◆ consoleLocals()
| void* pqPythonShell::consoleLocals |
( |
| ) |
|
Returns the interactive console context (the locals() dict).
You can use static_cast<PythonObject*>() to convert the void pointer. See vtkPythonInteractiveInterpreter::GetInteractiveConsoleLocalsPyObject().
◆ setFontSize()
| void pqPythonShell::setFontSize |
( |
int |
fontSize | ) |
|
Set/get the font size in points for the Python shell text.
◆ printMessage
| void pqPythonShell::printMessage |
( |
const QString & |
| ) |
|
|
slot |
Prints some text on the shell.
◆ clear
| void pqPythonShell::clear |
( |
| ) |
|
|
slot |
Clears the terminal.
This does not change the state of the Python interpreter, just clears the text shown in the Widget.
◆ executeScript
| void pqPythonShell::executeScript |
( |
const QString & |
| ) |
|
|
slot |
Execute an arbitrary python script/string.
This simply execute the Python script in the global Python interpreter.
◆ reset
| void pqPythonShell::reset |
( |
| ) |
|
|
slot |
Resets the python interactive interpreter.
This does not affect the global Python interpreter. If the interactive interpreter hasn't been initialized this has no effect.
◆ isExecuting
| bool pqPythonShell::isExecuting |
( |
| ) |
const |
|
slot |
Returns true is the shell is currently executing a script/command.
◆ printString
◆ setPreamble
| static void pqPythonShell::setPreamble |
( |
const QStringList & |
statements | ) |
|
|
staticslot |
Set a list of statements to be run each time the interpreter is reset.
By default, this imports the paraview.simple module. If you call this method, be aware that the preamble is assumed not to have any multi-line statements.
◆ preamble
| static const QStringList& pqPythonShell::preamble |
( |
| ) |
|
|
staticslot |
◆ initialize
| void pqPythonShell::initialize |
( |
| ) |
|
|
slot |
Initialize the Python interpreter in the shell, if not already.
Has no effect if the interpreter has already been initialized.
◆ executing
| void pqPythonShell::executing |
( |
bool |
starting | ) |
|
|
signal |
signal fired whenever the shell starts (starting=true) and finishes (starting=false) executing a Python command/script.
This can be used by the UI to block user input while the script is executing.
◆ pushScript
| void pqPythonShell::pushScript |
( |
const QString & |
| ) |
|
|
protectedslot |
◆ runScript
| void pqPythonShell::runScript |
( |
| ) |
|
|
protectedslot |
◆ PS1()
| static const char* pqPythonShell::PS1 |
( |
| ) |
|
|
inlinestaticprotected |
◆ PS2()
| static const char* pqPythonShell::PS2 |
( |
| ) |
|
|
inlinestaticprotected |
◆ prompt()
| bool pqPythonShell::prompt |
( |
const QString & |
indent = QString() | ) |
|
|
protected |
Show the user-input prompt, if needed.
Returns true if the prompt was re-rendered, otherwise false.
◆ HandleInterpreterEvents()
| void pqPythonShell::HandleInterpreterEvents |
( |
vtkObject * |
caller, |
|
|
unsigned long |
eventid, |
|
|
void * |
calldata |
|
) |
| |
|
protected |
◆ pqInternals
◆ ConsoleWidget
◆ Prompt
| const char* pqPythonShell::Prompt |
|
protected |
◆ Preamble
| QStringList pqPythonShell::Preamble |
|
staticprotected |
The documentation for this class was generated from the following file: