Utility class for running Python commands from various parts of QGIS.
More...
#include <qgspythonrunner.h>
|
static bool | eval (const QString &command, QString &result) |
| Eval a Python statement.
|
|
static bool | isValid () |
| Returns true if the runner has an instance (and thus is able to run commands)
|
|
static bool | run (const QString &command, const QString &messageOnError=QString()) |
| Execute a Python statement.
|
|
static bool | runFile (const QString &filename, const QString &messageOnError=QString()) |
| Execute a Python filename, showing an error message if one occurred.
|
|
static bool | setArgv (const QStringList &arguments, const QString &messageOnError=QString()) |
| Set sys.argv.
|
|
static void | setInstance (QgsPythonRunner *runner) |
| Assign an instance of Python runner so that run() can be used.
|
|
|
| QgsPythonRunner ()=default |
| Protected constructor: can be instantiated only from children.
|
|
virtual | ~QgsPythonRunner ()=default |
|
virtual bool | evalCommand (QString command, QString &result)=0 |
| Evaluates the given expression, producing a result.
|
|
virtual bool | runCommand (QString command, QString messageOnError=QString())=0 |
| Runs the given statement.
|
|
virtual bool | runFileCommand (const QString &filename, const QString &messageOnError=QString())=0 |
| Runs the code from the given file.
|
|
virtual bool | setArgvCommand (const QStringList &arguments, const QString &messageOnError=QString())=0 |
| Sets sys.argv to the given arguments.
|
|
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.
Definition at line 32 of file qgspythonrunner.h.
◆ QgsPythonRunner()
QgsPythonRunner::QgsPythonRunner |
( |
| ) |
|
|
protecteddefault |
Protected constructor: can be instantiated only from children.
◆ ~QgsPythonRunner()
virtual QgsPythonRunner::~QgsPythonRunner |
( |
| ) |
|
|
protectedvirtualdefault |
◆ eval()
bool QgsPythonRunner::eval |
( |
const QString & |
command, |
|
|
QString & |
result |
|
) |
| |
|
static |
◆ evalCommand()
virtual bool QgsPythonRunner::evalCommand |
( |
QString |
command, |
|
|
QString & |
result |
|
) |
| |
|
protectedpure virtual |
Evaluates the given expression, producing a result.
◆ 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 |
◆ runCommand()
virtual bool QgsPythonRunner::runCommand |
( |
QString |
command, |
|
|
QString |
messageOnError = QString() |
|
) |
| |
|
protectedpure virtual |
Runs the given statement.
◆ runFile()
bool QgsPythonRunner::runFile |
( |
const QString & |
filename, |
|
|
const QString & |
messageOnError = QString() |
|
) |
| |
|
static |
Execute a Python filename, showing an error message if one occurred.
- Returns
- true if no error occurred
Definition at line 42 of file qgspythonrunner.cpp.
◆ runFileCommand()
virtual bool QgsPythonRunner::runFileCommand |
( |
const QString & |
filename, |
|
|
const QString & |
messageOnError = QString() |
|
) |
| |
|
protectedpure virtual |
Runs the code from the given file.
◆ setArgv()
bool QgsPythonRunner::setArgv |
( |
const QStringList & |
arguments, |
|
|
const QString & |
messageOnError = QString() |
|
) |
| |
|
static |
◆ setArgvCommand()
virtual bool QgsPythonRunner::setArgvCommand |
( |
const QStringList & |
arguments, |
|
|
const QString & |
messageOnError = QString() |
|
) |
| |
|
protectedpure virtual |
Sets sys.argv to the given arguments.
◆ setInstance()
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 82 of file qgspythonrunner.cpp.
◆ sInstance
The documentation for this class was generated from the following files: