PythonScript Class Reference

`#include <PythonScript.h>`

Inheritance diagram for PythonScript:

## Public Slots

bool | compile (bool for_eval=true)
QVariant | eval ()
bool | exec ()
void | setContext (QObject *context)
bool | setDouble (double val, const char *name)
bool | setInt (int val, const char *name)
bool | setQObject (QObject *val, const char *name)
Public Slots inherited from Script
virtual bool | compile (bool for_eval=true)
| Compile the Code. Return true if the implementation doesn't support compilation. More...
virtual QVariant | eval ()
| Evaluate the Code, returning QVariant() on an error / exception. More...
virtual bool | exec ()
| Execute the Code, returning false on an error / exception. More...
virtual bool | setDouble (double, const char *)
virtual bool | setInt (int, const char *)
virtual bool | setQObject (const QObject *, const char *)

## Public Member Functions

| PythonScript (PythonScripting *env, const QString &code, QObject *context=0, const QString &name="<input>")
void | write (const QString &text)
| ~PythonScript ()
Public Member Functions inherited from Script
virtual void | addCode (const QString &code)
| Append to the code that will be executed when calling exec() or eval() More...
const QString | code () const
| Return the code that will be executed when calling exec() or eval() More...
QObject * | context () const
| Return the context in which the code is to be executed. More...
bool | emitErrors () const
| Return whether errors / exceptions are to be emitted or silently ignored. More...
const QString | name () const
| Like QObject::name, but with unicode support. More...
| Script (ScriptingEnv *env, const QString &code, QObject *context=0, const QString &name="<input>")
ScriptingEnv * | scriptingEnv ()
virtual void | setCode (const QString &code)
| Set the code that will be executed when calling exec() or eval() More...
virtual void | setContext (QObject *context)
| Set the context in which the code is to be executed. More...
void | setEmitErrors (bool yes)
| Set whether errors / exceptions are to be emitted or silently ignored. More...
void | setName (const QString &name)
| Like QObject::setName, but with unicode support. More...
| ~Script ()

## Private Member Functions

void | beginStdoutRedirect ()
void | endStdoutRedirect ()
PythonScripting * | env ()

## Private Attributes

bool | hasOldGlobals
bool | isFunction
PyObject * | modGlobalDict
PyObject * | modLocalDict
PyObject * | PyCode
PyObject * | stderrSave
PyObject * | stdoutSave

## Additional Inherited Members

Signals inherited from Script
void | codeChanged ()
| This is emitted whenever the code to be executed by exec() and eval() is changed. More...
void | error (const QString &message, const QString &scriptName, int lineNumber)
| signal an error condition / exception More...
void | print (const QString &output)
| output generated by the code More...
Protected Types inherited from Script
enum | compileStatus { notCompiled, isCompiled, compileErr }
Protected Member Functions inherited from Script
void | emit_error (const QString &message, int lineNumber)
Protected Attributes inherited from Script
QString | Code
enum Script::compileStatus | compiled
QObject * | Context
bool | EmitErrors
ScriptingEnv * | Env
QString | Name

## Constructor & Destructor Documentation

## PythonScript()

PythonScript::PythonScript | ( | PythonScripting * | env,
|  | const QString & | code,
|  | QObject * | context = `0`,
|  | const QString & | name = `"<input>"`
| ) |  |

References Script::Context, env(), modGlobalDict, modLocalDict, PyCode, and setQObject().

## ~PythonScript()

PythonScript::~PythonScript | ( |  | ) |

References modGlobalDict, modLocalDict, and PyCode.

## Member Function Documentation

## beginStdoutRedirect()

void PythonScript::beginStdoutRedirect | ( |  | ) |

private

References env(), PythonScripting::setQObject(), stderrSave, and stdoutSave.

Referenced by env(), eval(), and exec().

## compile

bool PythonScript::compile | ( | bool | for_eval = `true` | ) |

slot

References Script::Code, Script::compiled, Script::compileErr, Script::Context, Script::emit_error(), env(), hasOldGlobals, Script::isCompiled, modGlobalDict, modLocalDict, Script::Name, and PyCode.

Referenced by eval(), exec(), and write().

## endStdoutRedirect()

void PythonScript::endStdoutRedirect | ( |  | ) |

private

References env(), stderrSave, and stdoutSave.

Referenced by env(), eval(), and exec().

## env()

PythonScripting* PythonScript::env | ( |  | ) |

inline private

References beginStdoutRedirect(), endStdoutRedirect(), and Script::Env.

Referenced by beginStdoutRedirect(), compile(), endStdoutRedirect(), eval(), exec(), PythonScript(), setDouble(), setInt(), and setQObject().

## eval

QVariant PythonScript::eval | ( |  | ) |

slot

References beginStdoutRedirect(), compile(), Script::compiled, Script::emit_error(), endStdoutRedirect(), env(), PythonScripting::globalDict(), hasOldGlobals, Script::isCompiled, isFunction, modGlobalDict, modLocalDict, Script::notCompiled, and PyCode.

Referenced by write().

## exec

bool PythonScript::exec | ( |  | ) |

slot

References beginStdoutRedirect(), compile(), Script::compiled, Script::emit_error(), endStdoutRedirect(), env(), PythonScripting::globalDict(), hasOldGlobals, Script::isCompiled, isFunction, modGlobalDict, modLocalDict, Script::notCompiled, and PyCode.

Referenced by write().

## setContext

void PythonScript::setContext | ( | QObject * | context | ) |

slot

References Script::Context, Script::setContext(), and setQObject().

Referenced by write().

## setDouble

bool PythonScript::setDouble | ( | double | val,
|  | const char * | name
| ) |  |

slot

References Script::compiled, env(), modGlobalDict, modLocalDict, and Script::notCompiled.

Referenced by write().

## setInt

bool PythonScript::setInt | ( | int | val,
|  | const char * | name
| ) |  |

slot

References Script::compiled, env(), modGlobalDict, modLocalDict, and Script::notCompiled.

Referenced by write().

## setQObject

bool PythonScript::setQObject | ( | QObject * | val,
|  | const char * | name
| ) |  |

slot

References Script::compiled, env(), modGlobalDict, modLocalDict, and Script::notCompiled.

Referenced by PythonScript(), setContext(), and write().

## write()

void PythonScript::write | ( | const QString & | text | ) |

inline

References compile(), Script::context(), eval(), exec(), Script::name(), Script::print(), setContext(), setDouble(), setInt(), and setQObject().

## Member Data Documentation

## hasOldGlobals

bool PythonScript::hasOldGlobals

private

Referenced by compile(), eval(), and exec().

## isFunction

bool PythonScript::isFunction

private

Referenced by eval(), and exec().

## modGlobalDict

PyObject * PythonScript::modGlobalDict

private

Referenced by compile(), eval(), exec(), PythonScript(), setDouble(), setInt(), setQObject(), and ~PythonScript().

## modLocalDict

PyObject * PythonScript::modLocalDict

private

Referenced by compile(), eval(), exec(), PythonScript(), setDouble(), setInt(), setQObject(), and ~PythonScript().

## PyCode

PyObject* PythonScript::PyCode

private

Referenced by compile(), eval(), exec(), PythonScript(), and ~PythonScript().

## stderrSave

PyObject * PythonScript::stderrSave

private

Referenced by beginStdoutRedirect(), and endStdoutRedirect().

## stdoutSave

PyObject * PythonScript::stdoutSave

private

Referenced by beginStdoutRedirect(), and endStdoutRedirect().

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

- qtiplot/src/scripting/PythonScript.h
- qtiplot/src/scripting/PythonScript.cpp