--- a/src/eric7/Debugger/StartDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/Debugger/StartDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -20,22 +20,37 @@ class StartDialog(QDialog): """ Class implementing the Start Program dialog. - + It implements a dialog that is used to start an application for debugging. It asks the user to enter the commandline parameters, the working directory and whether exception reporting should be disabled. """ - def __init__(self, caption, lastUsedVenvName, argvList, wdList, envList, - exceptions, - parent=None, dialogType=0, modfuncList=None, - tracePython=False, autoClearShell=True, autoContinue=True, - enableMultiprocess=False, multiprocessNoDebugHistory=None, - configOverride=None, - forProject=False, scriptName="", scriptsList=None): + + def __init__( + self, + caption, + lastUsedVenvName, + argvList, + wdList, + envList, + exceptions, + parent=None, + dialogType=0, + modfuncList=None, + tracePython=False, + autoClearShell=True, + autoContinue=True, + enableMultiprocess=False, + multiprocessNoDebugHistory=None, + configOverride=None, + forProject=False, + scriptName="", + scriptsList=None, + ): """ Constructor - + @param caption the caption to be displayed @type str @param lastUsedVenvName name of the most recently used virtual @@ -89,54 +104,64 @@ """ super().__init__(parent) self.setModal(True) - + self.dialogType = dialogType if dialogType == 0: from .Ui_StartDebugDialog import Ui_StartDebugDialog + self.ui = Ui_StartDebugDialog() elif dialogType == 1: from .Ui_StartRunDialog import Ui_StartRunDialog + self.ui = Ui_StartRunDialog() elif dialogType == 2: from .Ui_StartCoverageDialog import Ui_StartCoverageDialog + self.ui = Ui_StartCoverageDialog() elif dialogType == 3: from .Ui_StartProfileDialog import Ui_StartProfileDialog + self.ui = Ui_StartProfileDialog() self.ui.setupUi(self) - + self.ui.venvComboBox.addItem("") self.ui.venvComboBox.addItems( - sorted(ericApp().getObject("VirtualEnvManager") - .getVirtualenvNames())) - + sorted(ericApp().getObject("VirtualEnvManager").getVirtualenvNames()) + ) + self.ui.scriptnamePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) self.ui.scriptnamePicker.setDefaultDirectory( - Preferences.getMultiProject("Workspace")) - self.ui.scriptnamePicker.setInsertPolicy( - QComboBox.InsertPolicy.InsertAtTop) + Preferences.getMultiProject("Workspace") + ) + self.ui.scriptnamePicker.setInsertPolicy(QComboBox.InsertPolicy.InsertAtTop) self.ui.scriptnamePicker.setSizeAdjustPolicy( - QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon) - self.ui.scriptnamePicker.setFilters(self.tr( - "Python Files (*.py *.py3);;" - "Python GUI Files (*.pyw *.pyw3);;" - "All Files (*)" - )) + QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon + ) + self.ui.scriptnamePicker.setFilters( + self.tr( + "Python Files (*.py *.py3);;" + "Python GUI Files (*.pyw *.pyw3);;" + "All Files (*)" + ) + ) self.ui.scriptnamePicker.setEnabled(not forProject) - + self.ui.workdirPicker.setMode(EricPathPickerModes.DIRECTORY_MODE) self.ui.workdirPicker.setDefaultDirectory( - Preferences.getMultiProject("Workspace")) - self.ui.workdirPicker.setInsertPolicy( - QComboBox.InsertPolicy.InsertAtTop) + Preferences.getMultiProject("Workspace") + ) + self.ui.workdirPicker.setInsertPolicy(QComboBox.InsertPolicy.InsertAtTop) self.ui.workdirPicker.setSizeAdjustPolicy( - QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon) - + QComboBox.SizeAdjustPolicy.AdjustToMinimumContentsLengthWithIcon + ) + self.clearButton = self.ui.buttonBox.addButton( - self.tr("Clear Histories"), QDialogButtonBox.ButtonRole.ActionRole) + self.tr("Clear Histories"), QDialogButtonBox.ButtonRole.ActionRole + ) self.editButton = self.ui.buttonBox.addButton( - self.tr("Edit History"), QDialogButtonBox.ButtonRole.ActionRole) - + self.tr("Edit History"), QDialogButtonBox.ButtonRole.ActionRole + ) + self.setWindowTitle(caption) self.ui.cmdlineCombo.clear() self.ui.cmdlineCombo.addItems(argvList) @@ -151,56 +176,58 @@ self.ui.exceptionCheckBox.setChecked(exceptions) self.ui.clearShellCheckBox.setChecked(autoClearShell) self.ui.consoleCheckBox.setEnabled( - Preferences.getDebugger("ConsoleDbgCommand") != "") + Preferences.getDebugger("ConsoleDbgCommand") != "" + ) self.ui.consoleCheckBox.setChecked(False) venvIndex = max(0, self.ui.venvComboBox.findText(lastUsedVenvName)) self.ui.venvComboBox.setCurrentIndex(venvIndex) self.ui.globalOverrideGroup.setChecked(configOverride["enable"]) self.ui.redirectCheckBox.setChecked(configOverride["redirect"]) - + self.ui.scriptnamePicker.addItems(scriptsList) self.ui.scriptnamePicker.setText(scriptName) - - if dialogType == 0: # start debug dialog - enableMultiprocessGlobal = Preferences.getDebugger( - "MultiProcessEnabled") + + if dialogType == 0: # start debug dialog + enableMultiprocessGlobal = Preferences.getDebugger("MultiProcessEnabled") self.ui.tracePythonCheckBox.setChecked(tracePython) self.ui.tracePythonCheckBox.show() self.ui.autoContinueCheckBox.setChecked(autoContinue) self.ui.multiprocessGroup.setEnabled(enableMultiprocessGlobal) self.ui.multiprocessGroup.setChecked( - enableMultiprocess & enableMultiprocessGlobal) + enableMultiprocess & enableMultiprocessGlobal + ) self.ui.multiprocessNoDebugCombo.clear() - self.ui.multiprocessNoDebugCombo.setToolTip(self.tr( - "Enter the list of programs or program patterns not to be" - " debugged separated by '{0}'.").format(os.pathsep) + self.ui.multiprocessNoDebugCombo.setToolTip( + self.tr( + "Enter the list of programs or program patterns not to be" + " debugged separated by '{0}'." + ).format(os.pathsep) ) if multiprocessNoDebugHistory: - self.ui.multiprocessNoDebugCombo.addItems( - multiprocessNoDebugHistory) + self.ui.multiprocessNoDebugCombo.addItems(multiprocessNoDebugHistory) self.ui.multiprocessNoDebugCombo.setCurrentIndex(0) - - if dialogType == 3: # start coverage or profile dialog + + if dialogType == 3: # start coverage or profile dialog self.ui.eraseCheckBox.setChecked(True) - + self.__clearHistoryLists = False self.__historiesModified = False - + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) - + def on_modFuncCombo_editTextChanged(self): """ Private slot to enable/disable the OK button. """ - self.ui.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setDisabled( - self.ui.modFuncCombo.currentText() == "") - + self.ui.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setDisabled( + self.ui.modFuncCombo.currentText() == "" + ) + def getData(self): """ Public method to retrieve the data entered into this dialog. - + @return a tuple of virtual environment, script name, argv, workdir, environment, exceptions flag, clear interpreter flag and run in console flag @@ -212,25 +239,26 @@ venvName = self.ui.venvComboBox.currentText() scriptName = ( self.ui.scriptnamePicker.currentText() - if self.ui.scriptnamePicker.isEnabled() else - "" + if self.ui.scriptnamePicker.isEnabled() + else "" ) - - return (venvName, - scriptName, - cmdLine, - workdir, - environment, - self.ui.exceptionCheckBox.isChecked(), - self.ui.clearShellCheckBox.isChecked(), - self.ui.consoleCheckBox.isChecked(), - ) - + + return ( + venvName, + scriptName, + cmdLine, + workdir, + environment, + self.ui.exceptionCheckBox.isChecked(), + self.ui.clearShellCheckBox.isChecked(), + self.ui.consoleCheckBox.isChecked(), + ) + def getGlobalOverrideData(self): """ Public method to retrieve the global configuration override data entered into this dialog. - + @return dictionary containing a flag indicating to activate the global override and a flag indicating a redirect of stdin/stdout/stderr @rtype dict @@ -239,12 +267,12 @@ "enable": self.ui.globalOverrideGroup.isChecked(), "redirect": self.ui.redirectCheckBox.isChecked(), } - + def getDebugData(self): """ Public method to retrieve the debug related data entered into this dialog. - + @return a tuple of a flag indicating, if the Python library should be traced as well, a flag indicating, that the debugger should not stop at the first executable line, a flag indicating to support @@ -253,18 +281,20 @@ @rtype tuple of (bool, bool, bool, str) """ if self.dialogType == 0: - return (self.ui.tracePythonCheckBox.isChecked(), - self.ui.autoContinueCheckBox.isChecked(), - self.ui.multiprocessGroup.isChecked(), - self.ui.multiprocessNoDebugCombo.currentText()) + return ( + self.ui.tracePythonCheckBox.isChecked(), + self.ui.autoContinueCheckBox.isChecked(), + self.ui.multiprocessGroup.isChecked(), + self.ui.multiprocessNoDebugCombo.currentText(), + ) else: return (False, False, False, "") - + def getCoverageData(self): """ Public method to retrieve the coverage related data entered into this dialog. - + @return flag indicating erasure of coverage info @rtype bool """ @@ -272,12 +302,12 @@ return self.ui.eraseCheckBox.isChecked() else: return False - + def getProfilingData(self): """ Public method to retrieve the profiling related data entered into this dialog. - + @return flag indicating erasure of profiling info @rtype bool """ @@ -285,36 +315,36 @@ return self.ui.eraseCheckBox.isChecked() else: return False - + def __clearHistories(self): """ Private slot to clear the combo boxes lists and record a flag to clear the lists. """ self.__clearHistoryLists = True - self.__historiesModified = False # clear catches it all - + self.__historiesModified = False # clear catches it all + cmdLine = self.ui.cmdlineCombo.currentText() workdir = self.ui.workdirPicker.currentText() environment = self.ui.environmentCombo.currentText() scriptName = self.ui.scriptnamePicker.currentText() - + self.ui.cmdlineCombo.clear() self.ui.workdirPicker.clear() self.ui.environmentCombo.clear() self.ui.scriptnamePicker.clear() - + self.ui.cmdlineCombo.addItem(cmdLine) self.ui.workdirPicker.addItem(workdir) self.ui.environmentCombo.addItem(environment) self.ui.scriptnamePicker.addItem("") self.ui.scriptnamePicker.setCurrentText(scriptName) - + if self.dialogType == 0: noDebugList = self.ui.multiprocessNoDebugCombo.currentText() self.ui.multiprocessNoDebugCombo.clear() self.ui.multiprocessNoDebugCombo.addItem(noDebugList) - + def __editHistory(self): """ Private slot to edit a history list. @@ -341,7 +371,9 @@ self.tr("Edit History"), self.tr("Select the history list to be edited:"), histories, - 0, False) + 0, + False, + ) if ok and historyKind: history = [] historiesIndex = histories.index(historyKind) @@ -351,12 +383,11 @@ else: combo = widgets[historiesIndex] if combo: - history = [ - combo.itemText(idx) for idx in range(combo.count()) - ] - + history = [combo.itemText(idx) for idx in range(combo.count())] + if history: from .StartHistoryEditDialog import StartHistoryEditDialog + dlg = StartHistoryEditDialog(history, self) if dlg.exec() == QDialog.DialogCode.Accepted: history = dlg.getHistory() @@ -364,31 +395,31 @@ if combo: combo.clear() combo.addItems(history) - + self.__historiesModified = True - + def historiesModified(self): """ Public method to test for modified histories. - + @return flag indicating modified histories @rtype bool """ return self.__historiesModified - + def clearHistories(self): """ Public method to test, if histories shall be cleared. - + @return flag indicating histories shall be cleared @rtype bool """ return self.__clearHistoryLists - + def getHistories(self): """ Public method to get the lists of histories. - + @return tuple containing the histories of script names, command line arguments, working directories, environment settings and no debug programs lists @@ -399,23 +430,27 @@ self.ui.multiprocessNoDebugCombo.itemText(index) for index in range(self.ui.multiprocessNoDebugCombo.count()) ] - if self.dialogType == 0 else - None + if self.dialogType == 0 + else None ) return ( self.ui.scriptnamePicker.getPathItems(), - [self.ui.cmdlineCombo.itemText(index) for index in range( - self.ui.cmdlineCombo.count())], + [ + self.ui.cmdlineCombo.itemText(index) + for index in range(self.ui.cmdlineCombo.count()) + ], self.ui.workdirPicker.getPathItems(), - [self.ui.environmentCombo.itemText(index) for index in range( - self.ui.environmentCombo.count())], + [ + self.ui.environmentCombo.itemText(index) + for index in range(self.ui.environmentCombo.count()) + ], noDebugHistory, ) - + def on_buttonBox_clicked(self, button): """ Private slot called by a button of the button box clicked. - + @param button button that was clicked @type QAbstractButton """