Kactus2
Kactus2 reference guide
Loading...
Searching...
No Matches
PythonInterpreter Class Reference

Convenience class for accessing Python interpreter. More...

#include <PythonInterpreter.h>

Inheritance diagram for PythonInterpreter:
WriteChannel

Public Slots

void executeString (QString const &string)
 
int runFile (QString const &filePath)
 
virtual void write (QString const &command) override final
 

Signals

void executeDone ()
 

Public Member Functions

 PythonInterpreter (WriteChannel *outputChannel, WriteChannel *errorChannel, bool printPromt=true, QObject *parent=nullptr)
 
 ~PythonInterpreter () final=default
 
void execute (std::string const &line)
 
void finalize ()
 
bool initialize (bool interactive=true)
 
- Public Member Functions inherited from WriteChannel
virtual ~WriteChannel ()=default
 The destructor.
 
virtual void write (QString const &text)=0
 

Additional Inherited Members

- Protected Member Functions inherited from WriteChannel
 WriteChannel ()=default
 The constructor.
 

Detailed Description

Convenience class for accessing Python interpreter.

Definition at line 28 of file PythonInterpreter.h.

Constructor & Destructor Documentation

◆ PythonInterpreter()

PythonInterpreter::PythonInterpreter ( WriteChannel * outputChannel,
WriteChannel * errorChannel,
bool printPromt = true,
QObject * parent = nullptr )
explicit

The constructor.

Parameters
[in]outputChannelChannel for standard messages and interpreter output.
[in]errorChannelChannel for error messages.
[in]printPromtFlag for enabling prompt printing.
[in]parentThe parent object.

Definition at line 24 of file PythonInterpreter.cpp.

◆ ~PythonInterpreter()

PythonInterpreter::~PythonInterpreter ( )
finaldefault

Member Function Documentation

◆ execute()

void PythonInterpreter::execute ( std::string const & line)

Execute a single line in the interpreter.

Parameters
[in]lineThe line to execute.

Definition at line 91 of file PythonInterpreter.cpp.

◆ executeDone

void PythonInterpreter::executeDone ( )
signal

◆ executeString

void PythonInterpreter::executeString ( QString const & string)
slot

Execute the given arbitrary long string in the interpreter.

Parameters
[in]stringThe string to execute.

Definition at line 182 of file PythonInterpreter.cpp.

◆ finalize()

void PythonInterpreter::finalize ( )

Clean up the interpreter state at end of life time.

Definition at line 74 of file PythonInterpreter.cpp.

◆ initialize()

bool PythonInterpreter::initialize ( bool interactive = true)

Initializes the interpreter. This function must be called before writing any commands with write().

Parameters
[in]interactiveFlag for enabling interactive std input. Set to true on command-line.
Returns
True, if initialization was successful, otherwise false.

Definition at line 38 of file PythonInterpreter.cpp.

◆ runFile

int PythonInterpreter::runFile ( QString const & filePath)
slot

Run a script from a given file.

Parameters
[in]filePathPath to the file to run.
Returns
Return value of the script or 1 if script file couldn't be opened.

Definition at line 205 of file PythonInterpreter.cpp.

◆ write

void PythonInterpreter::write ( QString const & command)
finaloverridevirtualslot

Write a command for interpreter to execute.

Parameters
[in]commandThe command to execute.

Definition at line 83 of file PythonInterpreter.cpp.


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