1 // SALOME SALOMEGUI : implementation of desktop and GUI kernel
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : PyInterp_PyQt.cxx
8 // Author : Christian CAREMOLI, Paul RASCLE, EDF
14 #include "PyInterp_PyQt.h"
16 #include "utilities.h"
18 extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l);
21 * constructor : the main SALOME Python interpreter is used for PyQt GUI.
22 * calls initialize method defined in base class, which calls virtual methods
23 * initstate & initcontext redefined here
25 PyInterp_PyQt::PyInterp_PyQt()
30 PyInterp_PyQt::~PyInterp_PyQt()
34 void PyInterp_PyQt::initState()
36 salomeAcquireLock(); //acquire python global lock (one for all interpreters)
37 SCRUTE(PyInterp_base::_gtstate);
38 _tstate=PyInterp_base::_gtstate;
39 PyThreadState_Swap(_tstate);
43 void PyInterp_PyQt::initContext()
45 _g = PyDict_New(); // create interpreter dictionnary context
46 PyObject *bimod = PyImport_ImportModule("__builtin__");
47 PyDict_SetItemString(_g, "__builtins__", bimod);
51 void PyInterp_PyQt::enter()
53 PyThreadState *oldstate;
56 oldstate=PyThreadState_Swap(_tstate);
60 void PyInterp_PyQt::quit()
67 void PyInterp_PyQt::run(const char *command)
72 code=Py_CompileString((char *)command,"PyGUI",Py_file_input);
76 Une erreur s est produite en general SyntaxError
82 r = PyEval_EvalCode(code,_g,_g);
87 Une erreur s est produite a l execution