diff -r 40a11619ee77 -r ea60ea85067a VirtualEnv/VirtualenvAddEditDialog.py --- a/VirtualEnv/VirtualenvAddEditDialog.py Sat Nov 03 14:16:43 2018 +0100 +++ b/VirtualEnv/VirtualenvAddEditDialog.py Sat Nov 03 14:19:21 2018 +0100 @@ -28,7 +28,7 @@ """ def __init__(self, manager, venvName="", venvDirectory="", venvInterpreter="", venvVariant=3, isGlobal=False, - parent=None): + isConda=False, execPath="", parent=None): """ Constructor @@ -44,6 +44,11 @@ @type int @param isGlobal flag indicating a global environment @type bool + @param isConda flag indicating an Anaconda virtual environment + @type bool + @param execPath search path string to be prepended to the PATH + environment variable + @type str @param parent reference to the parent widget @type QWidget """ @@ -65,11 +70,19 @@ self.pythonExecPicker.setDefaultDirectory( sys.executable.replace("w.exe", ".exe")) + self.execPathEdit.setToolTip(self.tr( + "Enter the executable search path to be prepended to the PATH" + " environment variable. Use '{0}' as the separator.").format( + os.pathsep) + ) + self.nameEdit.setText(venvName) self.targetDirectoryPicker.setText(venvDirectory) self.pythonExecPicker.setText(venvInterpreter) self.variantComboBox.setCurrentIndex(3 - venvVariant) self.globalCheckBox.setChecked(isGlobal) + self.anacondaCheckBox.setChecked(isConda) + self.execPathEdit.setText(execPath) self.__updateOk() @@ -150,14 +163,40 @@ """ self.__updateOk() + @pyqtSlot(bool) + def on_anacondaCheckBox_clicked(self, checked): + """ + Private slot handling a user click on this check box. + + @param checked state of the check box + @type bool + """ + if checked and not bool(self.execPathEdit.text()): + # prepopulate the execPathEdit widget + if Utilities.isWindowsPlatform(): + self.execPathEdit.setText(os.pathsep.join([ + self.targetDirectoryPicker.text(), + os.path.join(self.targetDirectoryPicker.text(), + "Scripts"), + os.path.join(self.targetDirectoryPicker.text(), + "Library", "bin"), + ])) + else: + self.execPathEdit.setText( + os.path.join(self.targetDirectoryPicker.text(), + "bin"), + ) + def getData(self): """ Public method to retrieve the entered data. @return tuple containing the logical name, the directory, the - interpreter of the virtual environment, the Python variant - and a flag indicating a global environment - @rtype tuple of (str, str, str, int, bool) + interpreter of the virtual environment, the Python variant, + a flag indicating a global environment, a flag indicating an + Anaconda environment and a string to be prepended to the PATH + environment variable + @rtype tuple of (str, str, str, int, bool,bool, str) """ return ( self.nameEdit.text(), @@ -165,4 +204,6 @@ self.pythonExecPicker.text(), 3 - self.variantComboBox.currentIndex(), self.globalCheckBox.isChecked(), + self.anacondaCheckBox.isChecked(), + self.execPathEdit.text(), )