Salome HOME
updated copyright message
[modules/gui.git] / tools / PyConsole / src / PyConsole_Console.cxx
index 3aaa52ccb12834d64c178bb8050302fb03095dc8..491ff8f1ccafdc6a6ce7efcaa2efd66e7858b5a4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -22,8 +22,8 @@
 // File   : PyConsole_Console.cxx
 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
 
-#include "PyConsole_Console.h"
 #include "PyConsole_Interp.h"
+#include "PyConsole_Console.h"
 #include "PyConsole_Editor.h"
 
 #include <QAction>
 
   This will create a console with default editor and interpreter.
 
-  To use custom editor and/or interpreter class with the console, you can use additional parameter
-  of the constructor; in this case you have to ensure that Python interpeter is initialized properly:
+  To use custom editor with the console, you can use alternative constructor:
   \code
-  PyConsole_Interp* interp = new PyConsole_Interp();
-  interp->initialize();
-  PyConsole_Console c(myWindow, new MyEditor(interp));
+  PyConsole_Console c(myWindow, new MyEditor());
   \endcode
 */  
 
+/*!
+  \brief Default constructor.
+
+  Creates new python console widget.
+  \param parent parent widget
+*/
+PyConsole_Console::PyConsole_Console( QWidget* parent )
+: QWidget( parent )
+{
+  init( 0 );
+}
+
 /*!
   \brief Constructor.
 
   Creates new python console widget.
   \param parent parent widget
-  \param interp python interpreter
+  \param editor python editor
 */
 PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Editor* editor )
 : QWidget( parent )
+{
+  init( editor );
+}
+
+/*!
+  \brief Initialize console widget.
+  \param editor python editor
+*/
+void PyConsole_Console::init( PyConsole_Editor* editor )
 {
   // initialize Python interpretator
   PyConsole_Interp* interp = editor ? editor->getInterp() : new PyConsole_Interp();
@@ -69,8 +87,8 @@ PyConsole_Console::PyConsole_Console( QWidget* parent, PyConsole_Editor* editor
   
   // create editor console
   QVBoxLayout* lay = new QVBoxLayout( this );
-  lay->setMargin( 0 );
-  myEditor = editor ? editor : new PyConsole_Editor( interp, this );
+  lay->setContentsMargins( 0, 0, 0 ,0 );
+  myEditor = editor ? editor : new PyConsole_Editor( this, interp );
   myEditor->setContextMenuPolicy( Qt::NoContextMenu );
   lay->addWidget( myEditor );