From: boulant Date: Tue, 6 Nov 2012 18:04:23 +0000 (+0000) Subject: Add an optional argument in pythonConsole to force the creation of the python console... X-Git-Tag: V6_6_0b1~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4388ad474876bb070ae8cb02896aa7d1afbf6b81;p=modules%2Fgui.git Add an optional argument in pythonConsole to force the creation of the python console in the case where it does not exist yet. --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 7b2bd00de..e3532938f 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1279,11 +1279,21 @@ LogWindow* LightApp_Application::logWindow() #ifndef DISABLE_PYCONSOLE /*! + This returns the python console integrated to the GUI. Depending + when you request the python console, this function could return + null. Then the optional parameter force (default to false) can be + set to force the creation of the python console if it is not done + already. + \param force - if true, the pythonConsole is created if it does not exist yet \return Python Console */ -PyConsole_Console* LightApp_Application::pythonConsole() +PyConsole_Console* LightApp_Application::pythonConsole(const bool force) { - return qobject_cast( dockWindow( WT_PyConsole ) ); + QWidget* wid = dockWindow( WT_PyConsole ); + if ( !wid and force==true) { + wid = getWindow(WT_PyConsole); + } + return qobject_cast( wid ); } #endif diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index f87251867..009432d29 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -108,7 +108,7 @@ public: LogWindow* logWindow(); SUIT_DataBrowser* objectBrowser(); #ifndef DISABLE_PYCONSOLE - PyConsole_Console* pythonConsole(); + PyConsole_Console* pythonConsole(const bool force = false); #endif virtual void updateObjectBrowser( const bool = true );