--- a/eric7/Plugins/ViewManagerPlugins/Tabview/Tabview.py Mon Aug 23 18:05:18 2021 +0200 +++ b/eric7/Plugins/ViewManagerPlugins/Tabview/Tabview.py Mon Aug 23 19:15:36 2021 +0200 @@ -241,6 +241,24 @@ """ Private method to initialize the tab context menu. """ + self.__startMenu = QMenu(self.tr("Start"), self) + self.__startMenu.addAction( + UI.PixmapCache.getIcon("runScript"), + self.tr('Run Script...'), + self.__contextMenuRunScript) + self.__startMenu.addAction( + UI.PixmapCache.getIcon("debugScript"), + self.tr('Debug Script...'), + self.__contextMenuDebugScript) + self.__startMenu.addAction( + UI.PixmapCache.getIcon("profileScript"), + self.tr('Profile Script...'), + self.__contextMenuProfileScript) + self.__startMenu.addAction( + UI.PixmapCache.getIcon("coverageScript"), + self.tr('Coverage run of Script...'), + self.__contextMenuCoverageScript) + self.__menu = QMenu(self) self.leftMenuAct = self.__menu.addAction( UI.PixmapCache.getIcon("1leftarrow"), @@ -278,6 +296,8 @@ self.tr("Open 'rejection' file"), self.__contextMenuOpenRejections) self.__menu.addSeparator() + self.__startAct = self.__menu.addMenu(self.__startMenu) + self.__menu.addSeparator() self.__menu.addAction( UI.PixmapCache.getIcon("printPreview"), self.tr("Print Preview"), self.__contextMenuPrintPreviewFile) @@ -311,8 +331,15 @@ rej = "{0}.rej".format(fileName) self.openRejectionsMenuAct.setEnabled( os.path.exists(rej)) + + ext = os.path.splitext(fileName)[1] + self.__startAct.setEnabled( + ext in Preferences.getDebugger( + "Python3Extensions").split() + ) else: self.openRejectionsMenuAct.setEnabled(False) + self.__startAct.setEnabled(False) self.contextMenuIndex = index self.leftMenuAct.setEnabled(index > 0) @@ -715,6 +742,42 @@ """ self.moveTab(self.contextMenuIndex, self.count() - 1) + def __contextMenuRunScript(self): + """ + Private method to run the editor script. + """ + if self.contextMenuEditor: + fn = self.contextMenuEditor.getFileName() + if fn: + ericApp().getObject("DebugUI").doRun(False, script=fn) + + def __contextMenuDebugScript(self): + """ + Private method to debug the editor script. + """ + if self.contextMenuEditor: + fn = self.contextMenuEditor.getFileName() + if fn: + ericApp().getObject("DebugUI").doDebug(False, script=fn) + + def __contextMenuProfileScript(self): + """ + Private method to profile the editor script. + """ + if self.contextMenuEditor: + fn = self.contextMenuEditor.getFileName() + if fn: + ericApp().getObject("DebugUI").doProfile(False, script=fn) + + def __contextMenuCoverageScript(self): + """ + Private method to run a coverage test of the editor script. + """ + if self.contextMenuEditor: + fn = self.contextMenuEditor.getFileName() + if fn: + ericApp().getObject("DebugUI").doCoverage(False, script=fn) + def __closeButtonClicked(self): """ Private method to handle the press of the close button.