Commit 8180aec2 authored by Nikita Sirgienko's avatar Nikita Sirgienko
Browse files

[Python] Set up argv for loaded worksheets

parent 74e5ddad
......@@ -20,6 +20,8 @@
#include "pythonserver.h"
#include <QFileInfo>
#include <QDir>
#include <Python.h>
PythonServer::PythonServer(QObject* parent) : QObject(parent), m_pModule(nullptr)
......@@ -141,6 +143,9 @@ QString PythonServer::getOutput() const
void PythonServer::setFilePath(const QString& path)
{
this->filePath = path;
PyRun_SimpleString(("import sys; sys.argv = ['" + path.toStdString() + "']").c_str());
QString dir = QFileInfo(path).absoluteDir().absolutePath();
PyRun_SimpleString(("import sys; sys.path.insert(0, '" + dir.toStdString() + "')").c_str());
PyRun_SimpleString(("__file__ = '"+path.toStdString()+"'").c_str());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment