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
12 #include "PyInterp_PyQt.h"
14 #include "utilities.h"
17 extern "C" PyObject * PyEval_EvalCode(PyObject *co, PyObject *g, PyObject *l);
20 * constructor : the main SALOME Python interpreter is used for PyQt GUI.
21 * calls initialize method defined in base class, which calls virtual methods
22 * initstate & initcontext redefined here
24 PyInterp_PyQt::PyInterp_PyQt()
29 PyInterp_PyQt::~PyInterp_PyQt()
33 void PyInterp_PyQt::initState()
35 salomeAcquireLock(); //acquire python global lock (one for all interpreters)
36 SCRUTE(PyInterp_base::_gtstate);
37 _tstate=PyInterp_base::_gtstate;
38 PyThreadState_Swap(_tstate);
42 void PyInterp_PyQt::initContext()
44 _g = PyDict_New(); // create interpreter dictionnary context
45 PyObject *bimod = PyImport_ImportModule("__builtin__");
46 PyDict_SetItemString(_g, "__builtins__", bimod);
50 void PyInterp_PyQt::enter()
52 PyThreadState *oldstate;
55 oldstate=PyThreadState_Swap(_tstate);
59 void PyInterp_PyQt::quit()
66 void PyInterp_PyQt::run(const char *command)
71 code=Py_CompileString((char *)command,"PyGUI",Py_file_input);
75 Une erreur s est produite en general SyntaxError
81 r = PyEval_EvalCode(code,_g,_g);
86 Une erreur s est produite a l execution