QGIS API Documentation  3.6.0-Noosa (5873452)
Static Public Member Functions | Protected Member Functions | Static Protected Attributes | List of all members
QgsPythonRunner Class Referenceabstract

Utility class for running Python commands from various parts of QGIS. More...

#include <qgspythonrunner.h>

Static Public Member Functions

static bool eval (const QString &command, QString &result)
 Eval a Python statement. More...
 
static bool isValid ()
 Returns true if the runner has an instance (and thus is able to run commands) More...
 
static bool run (const QString &command, const QString &messageOnError=QString())
 Execute a Python statement. More...
 
static void setInstance (QgsPythonRunner *runner)
 Assign an instance of Python runner so that run() can be used. More...
 

Protected Member Functions

 QgsPythonRunner ()=default
 Protected constructor: can be instantiated only from children. More...
 
virtual ~QgsPythonRunner ()=default
 
virtual bool evalCommand (QString command, QString &result)=0
 
virtual bool runCommand (QString command, QString messageOnError=QString())=0
 

Static Protected Attributes

static QgsPythonRunnersInstance = nullptr
 

Detailed Description

Utility class for running Python commands from various parts of QGIS.

There is no direct Python support in the core library, so it is expected that application with Python support creates a subclass that implements pure virtual function(s) during the initialization. The static methods will then work as expected.

Added in QGIS v?

Definition at line 33 of file qgspythonrunner.h.

Constructor & Destructor Documentation

◆ QgsPythonRunner()

QgsPythonRunner::QgsPythonRunner ( )
protecteddefault

Protected constructor: can be instantiated only from children.

◆ ~QgsPythonRunner()

virtual QgsPythonRunner::~QgsPythonRunner ( )
protectedvirtualdefault

Member Function Documentation

◆ eval()

bool QgsPythonRunner::eval ( const QString &  command,
QString &  result 
)
static

Eval a Python statement.

Definition at line 42 of file qgspythonrunner.cpp.

◆ evalCommand()

virtual bool QgsPythonRunner::evalCommand ( QString  command,
QString &  result 
)
protectedpure virtual

◆ isValid()

bool QgsPythonRunner::isValid ( )
static

Returns true if the runner has an instance (and thus is able to run commands)

Definition at line 23 of file qgspythonrunner.cpp.

◆ run()

bool QgsPythonRunner::run ( const QString &  command,
const QString &  messageOnError = QString() 
)
static

Execute a Python statement.

Definition at line 28 of file qgspythonrunner.cpp.

◆ runCommand()

virtual bool QgsPythonRunner::runCommand ( QString  command,
QString  messageOnError = QString() 
)
protectedpure virtual

◆ setInstance()

void QgsPythonRunner::setInstance ( QgsPythonRunner runner)
static

Assign an instance of Python runner so that run() can be used.

This method should be called during app initialization. Takes ownership of the object, deletes previous instance.

Definition at line 55 of file qgspythonrunner.cpp.

Member Data Documentation

◆ sInstance

QgsPythonRunner * QgsPythonRunner::sInstance = nullptr
staticprotected

Definition at line 63 of file qgspythonrunner.h.


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