/----------------------------------------------------------------------------
| 642 | |
| 643 | ////---------------------------------------------------------------------------- |
| 644 | void ctkPythonConsole::initialize(ctkAbstractPythonManager* newPythonManager) |
| 645 | { |
| 646 | Q_D(ctkPythonConsole); |
| 647 | |
| 648 | if (d->PythonManager) |
| 649 | { |
| 650 | qWarning() << "ctkPythonConsole already initialized !"; |
| 651 | return; |
| 652 | } |
| 653 | |
| 654 | // The call to mainContext() ensures that python has been initialized. |
| 655 | Q_ASSERT(newPythonManager); |
| 656 | newPythonManager->mainContext(); |
| 657 | Q_ASSERT(PythonQt::self()); // PythonQt should be initialized |
| 658 | |
| 659 | ctkPythonConsoleCompleter* completer = new ctkPythonConsoleCompleter(*newPythonManager); |
| 660 | this->setCompleter(completer); |
| 661 | |
| 662 | d->PythonManager = newPythonManager; |
| 663 | |
| 664 | d->initializeInteractiveConsole(); |
| 665 | |
| 666 | this->connect(PythonQt::self(), SIGNAL(pythonStdOut(QString)), |
| 667 | this, SLOT(printOutputMessage(QString))); |
| 668 | this->connect(PythonQt::self(), SIGNAL(pythonStdErr(QString)), |
| 669 | this, SLOT(printErrorMessage(QString))); |
| 670 | |
| 671 | PythonQt::self()->setRedirectStdInCallback( |
| 672 | ctkConsole::stdInRedirectCallBack, reinterpret_cast<void*>(this)); |
| 673 | |
| 674 | // Set primary and secondary prompt |
| 675 | this->setPs1(">>> "); |
| 676 | this->setPs2("... "); |
| 677 | |
| 678 | this->reset(); |
| 679 | |
| 680 | // Expose help() function |
| 681 | QStringList helpImportCode; |
| 682 | helpImportCode << "from pydoc import help"; |
| 683 | d->PythonManager->executeString(helpImportCode.join("\n")); |
| 684 | |
| 685 | this->setDisabled(false); |
| 686 | } |
| 687 | |
| 688 | //---------------------------------------------------------------------------- |
| 689 | QString ctkPythonConsole::ps1() const |
nothing calls this directly
no test coverage detected