// create editor console
QVBoxLayout* lay = new QVBoxLayout( this );
lay->setMargin( 0 );
- myEditor = new PyConsole_Editor( myInterp, this );
- myEditor->viewport()->installEventFilter( this );
- lay->addWidget( myEditor );
+ setEditor( new PyConsole_Editor( myInterp, this ) );
createActions();
}
{
}
+/*!
+ \brief Set python console editor widget
+ \param editor
+*/
+void PyConsole_Console::setEditor( PyConsole_Editor* theEditor )
+{
+ QVBoxLayout* lay = dynamic_cast<QVBoxLayout*>( layout() );
+ if ( !lay || theEditor == myEditor )
+ return;
+
+ if ( myEditor ) {
+ lay->removeWidget( myEditor );
+ delete myEditor;
+ }
+ myEditor = theEditor;
+ myEditor->viewport()->installEventFilter( this );
+ lay->addWidget( myEditor );
+}
+
/*!
\brief Execute python command in the interpreter.
\param command string with command and arguments
PyConsole_Console( QWidget* parent, PyConsole_Interp* interp = 0 );
virtual ~PyConsole_Console();
+ void setEditor( PyConsole_Editor* );
+
//! \brief Get python interperter
PyConsole_Interp* getInterp() { return myInterp; }
QFont font() const;
void cut();
void paste();
void clear();
- void handleReturn();
+ virtual void handleReturn();
void onPyInterpChanged( PyConsole_Interp* );
-private:
+protected:
PyConsole_Interp* myInterp; //!< python interpreter
QString myCommandBuffer; //!< python comman buffer