PyConsole_Interp* SalomeApp_Application::createPyInterp()
{
- return new SalomeApp_PyInterp;
+ return new SalomeApp_PyInterp( resourceMgr() );
}
#endif // DISABLE_PYCONSOLE
// Author : Nicolas REJNERI
#include "SalomeApp_PyInterp.h"
+#include "SUIT_ResourceMgr.h"
/*!
\brief Constructor
*/
-SalomeApp_PyInterp::SalomeApp_PyInterp()
- : myFirstRun( true ), myFirstInitStudy( false )
+SalomeApp_PyInterp::SalomeApp_PyInterp( SUIT_ResourceMgr* resMgr )
+ : myFirstRun( true ), myFirstInitStudy( false ), myResourceMgr( resMgr )
{
}
{
if ( myFirstRun ) {
myFirstRun = false;
+ QStringList parameters = myResourceMgr->parameters( "pythonpath" );
+ foreach ( QString parameter, parameters ) {
+ QStringList paths = myResourceMgr->stringValue( "pythonpath", parameter ).split( ";;" );
+ int index = 0;
+ foreach( QString path, paths )
+ simpleRun( QString( "import sys; sys.path.insert(%1, '%2')" ).arg( index++ ).arg( path ).toUtf8().constData(), false );
+ }
int ret = simpleRun( "from Help import *", false );
if ( ret )
return ret;
#include <PyConsole_Interp.h>
+class SUIT_ResourceMgr;
+
class SalomeApp_PyInterp : public PyConsole_Interp
{
friend class SalomeApp_Application;
virtual void closeContext();
protected:
- SalomeApp_PyInterp();
+ SalomeApp_PyInterp(SUIT_ResourceMgr*);
virtual bool initContext();
virtual int beforeRun();
private:
bool myFirstRun;
bool myFirstInitStudy;
+ SUIT_ResourceMgr* myResourceMgr;
};
#endif // SALOMEAPP_PYINTERP_H