QIcon(":pictures/open.png"), QKeySequence::Open);
aCommand->connectTo(this, SLOT(onOpen()));
+ aCommand = aGroup->addFeature("EXEC_CMD", tr("Launch Script"), tr("Launch Python script file"),
+ QIcon(":pictures/assembly.png"), QKeySequence());
+ aCommand->connectTo(this, SLOT(onFileExec()));
+
aCommand = aGroup->addFeature("PREF_CMD", tr("Preferences"), tr("Edit preferences"),
QIcon(":pictures/preferences.png"), QKeySequence::Preferences);
aCommand->connectTo(this, SLOT(onPreferences()));
updateCommandStatus();
}
+
+#ifndef HAVE_SALOME
+#include <PyConsole_Console.h>
+void XGUI_Workshop::onFileExec()
+{
+ QString aScript = QFileDialog::getOpenFileName(myMainWindow, tr("Open script"),
+ QString(), "Python script (*.py)");
+
+ if (!aScript.isNull()) {
+ PyConsole_Console* aConsole = myMainWindow->pythonConsole();
+ aConsole->execAndWait(QString("f = open('%1', 'rb')").arg(aScript));
+ QString aExecStr =
+ QString("exec(compile(f.read(), '%1', 'exec'))").arg(aScript);
+ aConsole->execAndWait(aExecStr);
+ aConsole->execAndWait("f.close()");
+ }
+}
+#endif