Skip to content

Commit 993d15e

Browse files
Charles PIGNEROLnicolaslg
authored andcommitted
Issue #234. Added the lima binding to the Python environment. WARNING: requires lima v 7.12.1 for proper operation, which should be available next week.
1 parent dfc4794 commit 993d15e

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/QtComponents/QtMgx3DMainWindow.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3521,7 +3521,8 @@ void QtMgx3DMainWindow::showReady ( )
35213521
CHECK_NULL_PTR_ERROR(_pythonPanel)
35223522
_pythonPanel->setInterpreterName("Magix3D interpreter");
35233523
// On facilite la tache de l'utilisateur : récupération du contexte de cette session :
3524-
char *env = getenv("MGX3D_PATH");
3524+
char* env = getenv ("MGX3D_PATH");
3525+
char* limaEnv = getenv ("LIMA_PATH");
35253526
if (0 != env)
35263527
{
35273528
_pythonPanel->executeCommand("import sys");
@@ -3532,6 +3533,20 @@ void QtMgx3DMainWindow::showReady ( )
35323533
UTF8String importLine(Charset::UTF_8);
35333534
importLine << "import pyMagix3D as " << getMgx3DAlias();
35343535
_pythonPanel->executeCommand(importLine);
3536+
3537+
if (0 != limaEnv)
3538+
{
3539+
const string comment = PythonLogOutputStream::toComment (UTF8String ("Pour une utilisation directe et scriptée de l'API Lima :", Charset::UTF_8));
3540+
_pythonPanel->executeCommand (comment);
3541+
const string limaPath (limaEnv);
3542+
UTF8String limaPathCmd (Charset::UTF_8);
3543+
limaPathCmd << "sys.path.append(\"" << limaPath << "\")";
3544+
_pythonPanel->executeCommand (limaPathCmd);
3545+
UTF8String limaImportLine (Charset::UTF_8);
3546+
limaImportLine << "from LimaScripting import *";
3547+
_pythonPanel->executeCommand (limaImportLine);
3548+
} // if (0 != limaEnv)
3549+
35353550
UTF8String contextLine(Charset::UTF_8);
35363551
contextLine << getContextAlias() << " = " << getMgx3DAlias()
35373552
<< ".getContext(\"" << getContext().getName() << "\")";
@@ -3573,17 +3588,6 @@ void QtMgx3DMainWindow::showReady ( )
35733588
<< "L'exécution de commandes Python pourrait ne pas fonctionner.";
35743589
log(WarningLog(error));
35753590
} // else if (0 != env)
3576-
env = getenv ("LIMA_PATH");
3577-
if (0 != env)
3578-
{
3579-
const string limaPath (env);
3580-
UTF8String path (Charset::UTF_8);
3581-
path << "sys.path.append(\"" << limaPath << "\")";
3582-
_pythonPanel->executeCommand (path);
3583-
UTF8String importLine (Charset::UTF_8);
3584-
importLine << "from LimaScripting import *";
3585-
_pythonPanel->executeCommand (importLine);
3586-
} // if (0 != env)
35873591
} // QtMgx3DMainWindow::initPythonScripting
35883592

35893593

0 commit comments

Comments
 (0)