Debugger/StartDialog.py

changeset 6352
4bdc6503df81
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
--- a/Debugger/StartDialog.py	Sun Jun 17 13:09:00 2018 +0200
+++ b/Debugger/StartDialog.py	Sun Jun 17 16:56:10 2018 +0200
@@ -12,6 +12,7 @@
 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QComboBox, QInputDialog
 
 from E5Gui.E5PathPicker import E5PathPickerModes
+from E5Gui.E5Application import e5App
 
 import Preferences
 
@@ -25,7 +26,7 @@
     the commandline parameters, the working directory and
     whether exception reporting should be disabled.
     """
-    def __init__(self, caption, interpreterList, argvList, wdList, envList,
+    def __init__(self, caption, lastUsedVenvName, argvList, wdList, envList,
                  exceptions,
                  parent=None, dialogType=0, modfuncList=None,
                  tracePython=False, autoClearShell=True, autoContinue=True,
@@ -33,13 +34,21 @@
         """
         Constructor
         
-        @param caption the caption to be displayed (string)
-        @param interpreterList list of interpreters (list of string)
-        @param argvList history list of commandline arguments (list of strings)
-        @param wdList history list of working directories (list of strings)
-        @param envList history list of environment settings (list of strings)
-        @param exceptions exception reporting flag (boolean)
-        @param parent parent widget of this dialog (QWidget)
+        @param caption the caption to be displayed
+        @type str
+        @param lastUsedVenvName name of the most recently used virtual
+            environment
+        @type str
+        @param argvList history list of command line arguments
+        @type list of str
+        @param wdList history list of working directories
+        @type list of str
+        @param envList history list of environment parameter settings
+        @type list of str
+        @param exceptions exception reporting flag
+        @type bool
+        @param parent parent widget of this dialog
+        @type QWidget
         @param dialogType type of the start dialog
                 <ul>
                 <li>0 = start debug dialog</li>
@@ -47,17 +56,22 @@
                 <li>2 = start coverage dialog</li>
                 <li>3 = start profile dialog</li>
                 </ul>
+        @type int (0 to 3)
         @keyparam modfuncList history list of module functions
-            (list of strings)
+        @type list of str
         @keyparam tracePython flag indicating if the Python library should
-            be traced as well (boolean)
+            be traced as well
+        @type bool
         @keyparam autoClearShell flag indicating, that the interpreter window
-            should be cleared automatically (boolean)
+            should be cleared automatically
+        @type bool
         @keyparam autoContinue flag indicating, that the debugger should not
-            stop at the first executable line (boolean)
-        @keyparam autoFork flag indicating the automatic fork mode (boolean)
+            stop at the first executable line
+        @type bool
+        @keyparam autoFork flag indicating the automatic fork mode
+        @type bool
         @keyparam forkChild flag indicating to debug the child after forking
-            (boolean)
+        @type bool
         """
         super(StartDialog, self).__init__(parent)
         self.setModal(True)
@@ -77,10 +91,10 @@
             self.ui = Ui_StartProfileDialog()
         self.ui.setupUi(self)
         
-        self.ui.interpreterPicker.setMode(E5PathPickerModes.OpenFileMode)
-        self.ui.interpreterPicker.setInsertPolicy(QComboBox.InsertAtTop)
-        self.ui.interpreterPicker.setSizeAdjustPolicy(
-            QComboBox.AdjustToMinimumContentsLength)
+        self.ui.venvComboBox.addItem("")
+        self.ui.venvComboBox.addItems(
+            sorted(e5App().getObject("VirtualEnvManager")
+                   .getVirtualenvNames()))
         
         self.ui.workdirPicker.setMode(E5PathPickerModes.DirectoryMode)
         self.ui.workdirPicker.setDefaultDirectory(
@@ -110,10 +124,8 @@
         self.ui.consoleCheckBox.setEnabled(
             Preferences.getDebugger("ConsoleDbgCommand") != "")
         self.ui.consoleCheckBox.setChecked(False)
-        self.ui.interpreterPicker.clear()
-        self.ui.interpreterPicker.addItems(interpreterList)
-        if len(interpreterList) > 0:
-            self.ui.interpreterPicker.setCurrentIndex(0)
+        venvIndex = max(0, self.ui.venvComboBox.findText(lastUsedVenvName))
+        self.ui.venvComboBox.setCurrentIndex(venvIndex)
         
         if dialogType == 0:        # start debug dialog
             self.ui.tracePythonCheckBox.setChecked(tracePython)
@@ -153,9 +165,9 @@
         cmdLine = self.ui.cmdlineCombo.currentText()
         workdir = self.ui.workdirPicker.currentText()
         environment = self.ui.environmentCombo.currentText()
-        interpreter = self.ui.interpreterPicker.currentText()
+        venvName = self.ui.venvComboBox.currentText()
         
-        return (interpreter,
+        return (venvName,
                 cmdLine,
                 workdir,
                 environment,
@@ -227,17 +239,14 @@
         cmdLine = self.ui.cmdlineCombo.currentText()
         workdir = self.ui.workdirPicker.currentText()
         environment = self.ui.environmentCombo.currentText()
-        interpreter = self.ui.interpreterPicker.currentText()
         
         self.ui.cmdlineCombo.clear()
         self.ui.workdirPicker.clear()
         self.ui.environmentCombo.clear()
-        self.ui.interpreterPicker.clear()
         
         self.ui.cmdlineCombo.addItem(cmdLine)
         self.ui.workdirPicker.addItem(workdir)
         self.ui.environmentCombo.addItem(environment)
-        self.ui.interpreterPicker.addItem(interpreter)
     
     def __editHistory(self):
         """
@@ -245,7 +254,6 @@
         """
         histories = [
             "",
-            self.tr("Interpreter"),
             self.tr("Command Line"),
             self.tr("Working Directory"),
             self.tr("Environment"),
@@ -258,13 +266,11 @@
             0, False)
         if ok and historyKind:
             historiesIndex = histories.index(historyKind)
-            if historiesIndex == 3:
+            if historiesIndex == 2:
                 history = self.ui.workdirPicker.getPathItems()
-            elif historiesIndex == 1:
-                history = self.ui.interpreterPicker.getPathItems()
             else:
                 history = []
-                if historiesIndex == 2:
+                if historiesIndex == 1:
                     combo = self.ui.cmdlineCombo
                 else:
                     combo = self.ui.environmentCombo
@@ -276,10 +282,8 @@
             if dlg.exec_() == QDialog.Accepted:
                 history = dlg.getHistory()
                 if historiesIndex == 1:
-                    combo = self.ui.interpreterPicker
+                    combo = self.ui.cmdlineCombo
                 elif historiesIndex == 2:
-                    combo = self.ui.cmdlineCombo
-                elif historiesIndex == 3:
                     combo = self.ui.workdirPicker
                 else:
                     combo = self.ui.environmentCombo
@@ -320,7 +324,6 @@
             self.ui.workdirPicker.getPathItems(),
             [self.ui.environmentCombo.itemText(index) for index in range(
                 self.ui.environmentCombo.count())],
-            self.ui.interpreterPicker.getPathItems(),
         )
     
     def on_buttonBox_clicked(self, button):

eric ide

mercurial