Exemplo n.º 1
0
milxQtPythonConsole::milxQtPythonConsole(QWidget* parent, const PythonQtObjectPtr& context, Qt::WindowFlags windowFlags)
        : QTextEdit(parent)
{

    setWindowFlags(windowFlags);

    _defaultTextCharacterFormat = currentCharFormat();
    _context                    = context;
    _historyPosition            = 0;
    _hadError                   = false;

    _completer = new QCompleter(this);
    _completer->setWidget(this);
    QObject::connect(_completer, SIGNAL(activated(const QString&)),
                     this, SLOT(insertCompletion(const QString&)));

    QTextEdit::clear();
    consoleMessage("milxQt Python Console\nMain window is 'MainWindow' and displayed windows are 'rnd_<name>', 'img_<name>' and 'mdl_<name>'\nFile IO can be done using 'milxQtFile'.");
    appendCommandPrompt();

    createActions();

    createConnections();

    readSettings();
}
Exemplo n.º 2
0
void milxQtPythonConsole::executeLine(bool storeOnly)
{
    QTextCursor textCursor = this->textCursor();
    textCursor.movePosition(QTextCursor::End);

    // Select the text from the command prompt until the end of the block
    // and get the selected text.
    textCursor.setPosition(commandPromptPosition());
    textCursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor);
    QString code = textCursor.selectedText();

    // i don't know where this trailing space is coming from, blast it!
    if (code.endsWith(" "))
    {
        code.truncate(code.length()-1);
    }

    if (!code.isEmpty())
    {
        // Update the history
        _history << code;
        _historyPosition = _history.count();
        _currentMultiLineCode += code + "\n";

        if (!storeOnly)
        {
            executeCode(_currentMultiLineCode);
            _currentMultiLineCode = "";
        }
    }
    // Insert a new command prompt
    appendCommandPrompt(storeOnly);

}
Exemplo n.º 3
0
void milxQtPythonConsole::clear()
{

    QTextEdit::clear();
    appendCommandPrompt();
}
void PythonQtScriptingConsole::clear() {

  QTextEdit::clear();
  appendCommandPrompt();
}