-----------------------------------------------------------------------------
| 216 | |
| 217 | //----------------------------------------------------------------------------- |
| 218 | pqPythonShell::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 | //----------------------------------------------------------------------------- |
| 257 | pqPythonShell::~pqPythonShell() |
nothing calls this directly
no test coverage detected