ParaView
Public Types | Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
pqPythonShell Class Reference

pqPythonShell is a QWidget subclass that provides an interactive Python shell. More...

#include <pqPythonShell.h>

Inherits QWidget.

Collaboration diagram for pqPythonShell:
Collaboration graph
[legend]

Public Types

enum  PrintMode { STATUS, OUTPUT, ERROR }
 

Public Slots

void printMessage (const QString &)
 Prints some text on the shell. More...
 
void clear ()
 Clears the terminal. More...
 
void executeScript (const QString &)
 Execute an arbitrary python script/string. More...
 
void reset ()
 Resets the python interactive interpreter. More...
 
bool isExecuting () const
 Returns true is the shell is currently executing a script/command. More...
 
void printString (const QString &, PrintMode mode=STATUS)
 Use this method instead of calling pqConsoleWidget::printString() directly. More...
 
static void setPreamble (const QStringList &statements)
 Set a list of statements to be run each time the interpreter is reset. More...
 

Signals

void executing (bool starting)
 signal fired whenever the shell starts (starting=true) and finishes (starting=false) executing a Python command/script. More...
 

Public Member Functions

 pqPythonShell (QWidget *parent=0, Qt::WindowFlags flags=0)
 
 ~pqPythonShell ()
 
void * consoleLocals ()
 Returns the interactive console context (the locals() dict). More...
 

Protected Slots

void pushScript (const QString &)
 
void setExecuting (bool val)
 

Protected Member Functions

void setupInterpreter ()
 Called to setup the Python interpreter during startup or after the Python environment was finalized. More...
 
bool prompt (const QString &indent=QString())
 Show the user-input prompt, if needed. More...
 
void HandleInterpreterEvents (vtkObject *caller, unsigned long eventid, void *calldata)
 

Static Protected Member Functions

static const char * PS1 ()
 
static const char * PS2 ()
 

Protected Attributes

pqConsoleWidgetConsoleWidget
 
vtkPythonInteractiveInterpreter * Interpreter
 
const char * Prompt
 

Static Protected Attributes

static QStringList Preamble
 

Friends

class pqPythonManager
 

Detailed Description

pqPythonShell is a QWidget subclass that provides an interactive Python shell.

It uses vtkPythonInterpreter to provide an interactive Python terminal without starting a separate Python event loop.

Python will be initialized (if not already), when pqPythonShell is instantiated.

See also
pqConsoleWidget, pqPythonDialog.

Definition at line 51 of file pqPythonShell.h.

Member Enumeration Documentation

§ PrintMode

Enumerator
STATUS 
OUTPUT 
ERROR 

Definition at line 64 of file pqPythonShell.h.

Constructor & Destructor Documentation

§ pqPythonShell()

pqPythonShell::pqPythonShell ( QWidget *  parent = 0,
Qt::WindowFlags  flags = 0 
)

§ ~pqPythonShell()

pqPythonShell::~pqPythonShell ( )

Member Function Documentation

§ 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().

§ 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.

§ isExecuting

bool pqPythonShell::isExecuting ( ) const
inlineslot

Returns true is the shell is currently executing a script/command.

Definition at line 88 of file pqPythonShell.h.

§ printString

void pqPythonShell::printString ( const QString &  ,
PrintMode  mode = STATUS 
)
slot

Use this method instead of calling pqConsoleWidget::printString() directly.

That helps us keep track of whether we need to show the prompt or not.

§ 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.

§ 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

§ setExecuting

void pqPythonShell::setExecuting ( bool  val)
inlineprotectedslot

Definition at line 111 of file pqPythonShell.h.

§ PS1()

static const char* pqPythonShell::PS1 ( )
inlinestaticprotected

Definition at line 119 of file pqPythonShell.h.

§ PS2()

static const char* pqPythonShell::PS2 ( )
inlinestaticprotected

Definition at line 120 of file pqPythonShell.h.

§ setupInterpreter()

void pqPythonShell::setupInterpreter ( )
protected

Called to setup the Python interpreter during startup or after the Python environment was finalized.

§ 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

Friends And Related Function Documentation

§ pqPythonManager

friend class pqPythonManager
friend

Definition at line 125 of file pqPythonShell.h.

Member Data Documentation

§ ConsoleWidget

pqConsoleWidget* pqPythonShell::ConsoleWidget
protected

Definition at line 114 of file pqPythonShell.h.

§ Interpreter

vtkPythonInteractiveInterpreter* pqPythonShell::Interpreter
protected

Definition at line 115 of file pqPythonShell.h.

§ Prompt

const char* pqPythonShell::Prompt
protected

Definition at line 116 of file pqPythonShell.h.

§ Preamble

QStringList pqPythonShell::Preamble
staticprotected

Definition at line 117 of file pqPythonShell.h.


The documentation for this class was generated from the following file: