QtiPlot  0.9.8.2
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
PythonScripting Class Reference

#include <PythonScripting.h>

Inheritance diagram for PythonScripting:
ScriptingEnv

Public Member Functions

QString errorMsg ()
 
PyObjecteval (const QString &code, PyObject *argDict=NULL, const char *name="<qtiplot>")
 evaluate a Python expression More...
 
bool exec (const QString &code, PyObject *argDict=NULL, const char *name="<qtiplot>")
 execute a sequence of Python statements More...
 
const QStringList fileExtensions () const
 Return a list of file extensions commonly used for this language. More...
 
PyObjectglobalDict ()
 
bool initialize ()
 Part of the initialization is deferred from the constructor until after the signals have been connected. More...
 
bool isRunning () const
 whether asynchronuous execution is enabled (if supported by the implementation) More...
 
const QString mathFunctionDoc (const QString &name) const
 Return a documentation string for the given mathematical function. More...
 
const QStringList mathFunctions () const
 Return a list of supported mathematical functions. These should be imported into the global namespace. More...
 
ScriptnewScript (const QString &code, QObject *context, const QString &name="<input>")
 Instantiate the Script subclass matching the ScriptEnv subclass. More...
 
 PythonScripting (ApplicationWindow *parent)
 
bool setDouble (double, const char *, PyObject *dict=NULL)
 
bool setInt (int, const char *, PyObject *dict=NULL)
 
bool setQObject (QObject *, const char *, PyObject *dict)
 
bool setQObject (QObject *val, const char *name)
 
PyObjectsysDict ()
 
QString toString (PyObject *object, bool decref=false)
 like str(object) in Python More...
 
void write (const QString &text)
 
 ~PythonScripting ()
 
- Public Member Functions inherited from ScriptingEnv
ApplicationWindowapplication ()
 
const QString fileFilter () const
 Construct a filter expression from fileExtension(), suitable for QFileDialog. More...
 
bool initialized () const
 initialization of the interpreter may fail; or there could be other errors setting up the environment More...
 
 ScriptingEnv (ApplicationWindow *parent, const char *langName)
 
virtual QString stackTraceString ()
 If an exception / error occured, return a nicely formated stack backtrace. More...
 

Static Public Member Functions

static ScriptingEnvconstructor (ApplicationWindow *parent)
 

Static Public Attributes

static const char * langName = "Python"
 

Private Member Functions

bool loadInitFile (const QString &path)
 

Private Attributes

PyObjectglobals
 
PyObjectmath
 
PyObjectsys
 

Additional Inherited Members

- Public Slots inherited from ScriptingEnv
virtual void clear ()
 Clear the global environment. What exactly happens depends on the implementation. More...
 
void decref ()
 Decrease the reference count. This should only be called by scripted and Script to avoid segfaults. More...
 
void incref ()
 Increase the reference count. This should only be called by scripted and Script to avoid memory leaks. More...
 
virtual bool setDouble (double, const char *)
 
virtual bool setInt (int, const char *)
 
virtual void startExecution ()
 If the implementation supports asynchronuos execution, activate it. More...
 
virtual void stopExecution ()
 If the implementation supports asynchronuos execution, deactivate it. More...
 
- Signals inherited from ScriptingEnv
void error (const QString &message, const QString &scriptName, int lineNumber)
 signal an error condition / exception More...
 
void print (const QString &output)
 output that is not handled by a Script More...
 
- Protected Attributes inherited from ScriptingEnv
bool d_initialized
 whether the interpreter has been successfully initialized More...
 
ApplicationWindowd_parent
 the context in which we are running More...
 

Constructor & Destructor Documentation

PythonScripting::PythonScripting ( ApplicationWindow parent)
PythonScripting::~PythonScripting ( )

References globals, math, and sys.

Member Function Documentation

static ScriptingEnv* PythonScripting::constructor ( ApplicationWindow parent)
inlinestatic

References initialize(), and PythonScripting().

QString PythonScripting::errorMsg ( )
PyObject * PythonScripting::eval ( const QString &  code,
PyObject argDict = NULL,
const char *  name = "<qtiplot>" 
)

evaluate a Python expression

Evaluates code, using argDict (borrowed reference) as local dictionary or an empty one if argDict==NULL. name is the filename Python uses when reporting errors. Returns a new reference; NULL means caller has to do exception handling.

Referenced by write().

bool PythonScripting::exec ( const QString &  code,
PyObject argDict = NULL,
const char *  name = "<qtiplot>" 
)

execute a sequence of Python statements

Executes code, using argDict (borrowed reference) as local dictionary or an empty one if argDict==NULL. name is the filename Python uses when reporting errors. A false return value means caller has to do exception handling.

Referenced by write().

const QStringList PythonScripting::fileExtensions ( ) const
virtual

Return a list of file extensions commonly used for this language.

Reimplemented from ScriptingEnv.

Referenced by setQObject().

PyObject* PythonScripting::globalDict ( )
inline

References globals.

Referenced by PythonScript::eval(), and PythonScript::exec().

bool PythonScripting::initialize ( )
virtual

Part of the initialization is deferred from the constructor until after the signals have been connected.

Reimplemented from ScriptingEnv.

References ScriptingEnv::d_initialized, ScriptingEnv::d_parent, ApplicationWindow::d_python_config_folder, ScriptingEnv::initialized(), loadInitFile(), setQObject(), and sys.

Referenced by constructor().

bool PythonScripting::isRunning ( ) const
virtual

whether asynchronuous execution is enabled (if supported by the implementation)

Reimplemented from ScriptingEnv.

Referenced by write().

bool PythonScripting::loadInitFile ( const QString &  path)
private

Referenced by initialize(), and sysDict().

const QString PythonScripting::mathFunctionDoc ( const QString &  ) const
virtual

Return a documentation string for the given mathematical function.

Reimplemented from ScriptingEnv.

References math.

Referenced by setQObject().

const QStringList PythonScripting::mathFunctions ( ) const
virtual

Return a list of supported mathematical functions. These should be imported into the global namespace.

Reimplemented from ScriptingEnv.

References math.

Referenced by setQObject().

Script* PythonScripting::newScript ( const QString &  ,
QObject *  ,
const QString &  = "<input>" 
)
inlinevirtual

Instantiate the Script subclass matching the ScriptEnv subclass.

Reimplemented from ScriptingEnv.

References setQObject().

bool PythonScripting::setDouble ( double  val,
const char *  name,
PyObject dict = NULL 
)

References globals.

Referenced by setQObject().

bool PythonScripting::setInt ( int  val,
const char *  name,
PyObject dict = NULL 
)

References globals.

Referenced by setQObject().

bool PythonScripting::setQObject ( QObject *  val,
const char *  name,
PyObject dict 
)
bool PythonScripting::setQObject ( QObject *  val,
const char *  name 
)
inlinevirtual
PyObject* PythonScripting::sysDict ( )
inline

References loadInitFile(), and sys.

QString PythonScripting::toString ( PyObject object,
bool  decref = false 
)

like str(object) in Python

Convert object to a string. Steals a reference to object if decref is true; borrows otherwise.

Referenced by write().

void PythonScripting::write ( const QString &  text)
inline

Member Data Documentation

PyObject* PythonScripting::globals
private
const char * PythonScripting::langName = "Python"
static
PyObject* PythonScripting::math
private
PyObject* PythonScripting::sys
private

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