VirtualEnv/VirtualenvAddEditDialog.py

changeset 6362
ec32d1d7f525
parent 6349
17b3c75913de
child 6576
ea60ea85067a
diff -r 53f6bd7fb238 -r ec32d1d7f525 VirtualEnv/VirtualenvAddEditDialog.py
--- a/VirtualEnv/VirtualenvAddEditDialog.py	Fri Jun 22 18:18:23 2018 +0200
+++ b/VirtualEnv/VirtualenvAddEditDialog.py	Sat Jun 23 15:14:48 2018 +0200
@@ -27,7 +27,8 @@
     Class implementing a dialog to enter the data of a virtual environment.
     """
     def __init__(self, manager, venvName="", venvDirectory="",
-                 venvInterpreter="", venvVariant=3, parent=None):
+                 venvInterpreter="", venvVariant=3, isGlobal=False,
+                 parent=None):
         """
         Constructor
         
@@ -41,6 +42,8 @@
         @type str
         @param venvVariant Python variant of the virtual environment
         @type int
+        @param isGlobal flag indicating a global environment
+        @type bool
         @param parent reference to the parent widget
         @type QWidget
         """
@@ -66,8 +69,7 @@
         self.targetDirectoryPicker.setText(venvDirectory)
         self.pythonExecPicker.setText(venvInterpreter)
         self.variantComboBox.setCurrentIndex(3 - venvVariant)
-        self.globalCheckBox.setChecked(self.__editMode and
-                                       not bool(venvDirectory))
+        self.globalCheckBox.setChecked(isGlobal)
         
         self.__updateOk()
     
@@ -146,8 +148,6 @@
         @param checked state of the check box
         @type bool
         """
-        self.targetDirectoryPicker.setEnabled(not checked)
-        
         self.__updateOk()
     
     def getData(self):
@@ -155,20 +155,14 @@
         Public method to retrieve the entered data.
         
         @return tuple containing the logical name, the directory, the
-            interpreter of the virtual environment and the Python variant
-        @rtype tuple of (str, str, str, int)
+            interpreter of the virtual environment, the Python variant
+            and a flag indicating a global environment
+        @rtype tuple of (str, str, str, int, bool)
         """
-        if self.globalCheckBox.isChecked():
-            return (
-                self.nameEdit.text(),
-                "",
-                self.pythonExecPicker.text(),
-                3 - self.variantComboBox.currentIndex(),
-            )
-        else:
-            return (
-                self.nameEdit.text(),
-                self.targetDirectoryPicker.text(),
-                self.pythonExecPicker.text(),
-                3 - self.variantComboBox.currentIndex(),
-            )
+        return (
+            self.nameEdit.text(),
+            self.targetDirectoryPicker.text(),
+            self.pythonExecPicker.text(),
+            3 - self.variantComboBox.currentIndex(),
+            self.globalCheckBox.isChecked(),
+        )

eric ide

mercurial