Class: QgsPythonRunner¶
-
class
qgis.core.
QgsPythonRunner
¶ Bases:
sip.wrapper
Protected constructor: can be instantiated only from children
QgsPythonRunner(
QgsPythonRunner
)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?
Methods
Eval a Python statement
- param command
Returns
True
if the runner has an instance (and thus is able to run commands) *Execute a Python statement
- param command
Assign an instance of Python runner so that
run()
can be used.-
eval
(command: str) → Tuple[bool, str]¶ Eval a Python statement
- Parameters
command (str) –
- Return type
Tuple[bool, str]
-
evalCommand
(self, command: str, result: str) → bool¶ - Parameters
command (str) –
result (str) –
- Return type
bool
-
isValid
() → bool¶ Returns
True
if the runner has an instance (and thus is able to run commands) *- Return type
bool
-
run
(command: str, messageOnError: str = '') → bool¶ Execute a Python statement
- Parameters
command (str) –
messageOnError (str = '') –
- Return type
bool
-
runCommand
(self, command: str, messageOnError: str = '') → bool¶ - Parameters
command (str) –
messageOnError (str = '') –
- Return type
bool
-
setInstance
(runner: QgsPythonRunner)¶ 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. *- Parameters
runner (QgsPythonRunner) –