MCPcopy Create free account
hub / github.com/Kitware/ParaView / pqPythonShell

Method pqPythonShell

Qt/Python/pqPythonShell.cxx:218–254  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

216
217//-----------------------------------------------------------------------------
218pqPythonShell::pqPythonShell(QWidget* parentObject, Qt::WindowFlags _flags)
219 : Superclass(parentObject, _flags)
220 , ConsoleWidget(nullptr)
221 , Prompt(pqPythonShell::PS1())
222 , Prompted(false)
223 , Internals(new pqPythonShell::pqInternals(this))
224{
225 // The default preamble loads paraview.simple:
226 if (pqPythonShell::Preamble.empty())
227 {
228 pqPythonShell::Preamble += "from paraview.simple import *";
229 }
230
231 Ui::PythonShell& ui = this->Internals->Ui;
232
233 // install event filter to initialize Python on request.
234 // we use queued connection so that the cursor ends up after the prompt.
235 // Otherwise if user clicked for focus, the cursor will end up where ever the
236 // user clicked.
237 this->connect(
238 ui.consoleWidget, SIGNAL(consoleFocusInEvent()), SLOT(initialize()), Qt::QueuedConnection);
239
240 // Setup completer for the console widget.
241 pqPythonShellCompleter* completer =
242 new pqPythonShellCompleter(this, this->Internals->interpreter());
243 ui.consoleWidget->setCompleter(completer);
244
245 // Accept user input from the console and push it into the Python interpreter.
246 this->connect(
247 ui.consoleWidget, SIGNAL(executeCommand(const QString&)), SLOT(pushScript(const QString&)));
248
249 this->Internals->interpreter()->AddObserver(
250 vtkCommand::AnyEvent, this, &pqPythonShell::HandleInterpreterEvents);
251
252 // show the prompt so user knows that there's a Python shell to use.
253 this->prompt();
254}
255
256//-----------------------------------------------------------------------------
257pqPythonShell::~pqPythonShell()

Callers

nothing calls this directly

Calls 7

promptMethod · 0.95
PS1Function · 0.85
interpreterMethod · 0.80
initializeFunction · 0.50
emptyMethod · 0.45
connectMethod · 0.45
setCompleterMethod · 0.45

Tested by

no test coverage detected