3 //=============================================================================
4 // File : PyInterp_PyQt.cxx
5 // Created : ven fév 7 10:01:36 CET 2003
6 // Author : Christian CAREMOLI, Paul RASCLE, EDF
8 // Copyright : EDF 2003
10 //=============================================================================
12 #include "PyInterp_PyQt.h"
14 #include "utilities.h"
16 extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l);
19 * constructor : the main SALOME Python interpreter is used for PyQt GUI.
20 * calls initialize method defined in base class, which calls virtual methods
21 * initstate & initcontext redefined here
23 PyInterp_PyQt::PyInterp_PyQt()
28 PyInterp_PyQt::~PyInterp_PyQt()
32 void PyInterp_PyQt::initState()
34 salomeAcquireLock(); //acquire python global lock (one for all interpreters)
35 SCRUTE(PyInterp_base::_gtstate);
36 _tstate=PyInterp_base::_gtstate;
37 PyThreadState_Swap(_tstate);
41 void PyInterp_PyQt::initContext()
43 _g = PyDict_New(); // create interpreter dictionnary context
44 PyObject *bimod = PyImport_ImportModule("__builtin__");
45 PyDict_SetItemString(_g, "__builtins__", bimod);
49 void PyInterp_PyQt::enter()
51 PyThreadState *oldstate;
54 oldstate=PyThreadState_Swap(_tstate);
58 void PyInterp_PyQt::quit()
65 void PyInterp_PyQt::run(const char *command)
70 code=Py_CompileString((char *)command,"PyGUI",Py_file_input);
74 Une erreur s est produite en general SyntaxError
80 r = PyEval_EvalCode(code,_g,_g);
85 Une erreur s est produite a l execution