MCPcopy Create free account
hub / github.com/commontk/CTK / initPythonQt

Method initPythonQt

Libs/Scripting/Python/Core/ctkAbstractPythonManager.cpp:135–179  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

133
134//-----------------------------------------------------------------------------
135void ctkAbstractPythonManager::initPythonQt(int flags)
136{
137 Q_D(ctkAbstractPythonManager);
138
139 PythonQt::init(flags);
140
141 // Python maps SIGINT (control-c) to its own handler. We will remap it
142 // to the default so that control-c works.
143 #ifdef SIGINT
144 signal(SIGINT, SIG_DFL);
145 #endif
146
147 // Forward signal from PythonQt::self() to this instance of ctkAbstractPythonManager
148 this->connect(PythonQt::self(), SIGNAL(systemExitExceptionRaised(int)),
149 SIGNAL(systemExitExceptionRaised(int)));
150
151 this->connect(PythonQt::self(), SIGNAL(pythonStdOut(QString)),
152 SLOT(printStdout(QString)));
153 this->connect(PythonQt::self(), SIGNAL(pythonStdErr(QString)),
154 SLOT(printStderr(QString)));
155
156 PythonQt_init_QtBindings();
157
158 QStringList initCode;
159
160 // Update 'sys.path'
161 initCode << "import sys";
162 foreach (const QString& path, this->pythonPaths())
163 {
164 initCode << QString("sys.path.append(%1)").arg(QDir::fromNativeSeparators(path));
165 }
166
167 PythonQtObjectPtr _mainContext = PythonQt::self()->getMainModule();
168 _mainContext.evalScript(initCode.join("\n"));
169
170 this->preInitialization();
171 if (d->InitFunction)
172 {
173 (*d->InitFunction)();
174 }
175 emit this->pythonPreInitialized();
176
177 this->executeInitializationScripts();
178 emit this->pythonInitialized();
179}
180
181//-----------------------------------------------------------------------------
182bool ctkAbstractPythonManager::isPythonInitialized()const

Callers 1

initializeMethod · 0.95

Calls 4

preInitializationMethod · 0.95
connectMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected