VirtualEnv/VirtualenvAddEditDialog.py

changeset 6716
1c9d3b369ea8
parent 6645
ad476851d7e0
child 6719
705080ffd4a9
equal deleted inserted replaced
6711:a3aec8edaef5 6716:1c9d3b369ea8
26 """ 26 """
27 Class implementing a dialog to enter the data of a virtual environment. 27 Class implementing a dialog to enter the data of a virtual environment.
28 """ 28 """
29 def __init__(self, manager, venvName="", venvDirectory="", 29 def __init__(self, manager, venvName="", venvDirectory="",
30 venvInterpreter="", venvVariant=3, isGlobal=False, 30 venvInterpreter="", venvVariant=3, isGlobal=False,
31 isConda=False, execPath="", parent=None): 31 isConda=False, isRemote=False, execPath="", parent=None):
32 """ 32 """
33 Constructor 33 Constructor
34 34
35 @param manager reference to the virtual environment manager 35 @param manager reference to the virtual environment manager
36 @type VirtualenvManager 36 @type VirtualenvManager
43 @param venvVariant Python variant of the virtual environment 43 @param venvVariant Python variant of the virtual environment
44 @type int 44 @type int
45 @param isGlobal flag indicating a global environment 45 @param isGlobal flag indicating a global environment
46 @type bool 46 @type bool
47 @param isConda flag indicating an Anaconda virtual environment 47 @param isConda flag indicating an Anaconda virtual environment
48 @type bool
49 @param isRemote flag indicating a remotely accessed environment
48 @type bool 50 @type bool
49 @param execPath search path string to be prepended to the PATH 51 @param execPath search path string to be prepended to the PATH
50 environment variable 52 environment variable
51 @type str 53 @type str
52 @param parent reference to the parent widget 54 @param parent reference to the parent widget
80 self.targetDirectoryPicker.setText(venvDirectory) 82 self.targetDirectoryPicker.setText(venvDirectory)
81 self.pythonExecPicker.setText(venvInterpreter) 83 self.pythonExecPicker.setText(venvInterpreter)
82 self.variantComboBox.setCurrentIndex(3 - venvVariant) 84 self.variantComboBox.setCurrentIndex(3 - venvVariant)
83 self.globalCheckBox.setChecked(isGlobal) 85 self.globalCheckBox.setChecked(isGlobal)
84 self.anacondaCheckBox.setChecked(isConda) 86 self.anacondaCheckBox.setChecked(isConda)
87 self.remoteCheckBox.setChecked(isRemote)
85 self.execPathEdit.setText(execPath) 88 self.execPathEdit.setText(execPath)
86 89
87 self.__updateOk() 90 self.__updateOk()
88 91
89 def __updateOk(self): 92 def __updateOk(self):
102 self.__manager.isUnique(self.nameEdit.text()) 105 self.__manager.isUnique(self.nameEdit.text())
103 ) 106 )
104 107
105 if not self.globalCheckBox.isChecked(): 108 if not self.globalCheckBox.isChecked():
106 enable = ( 109 enable = (
107 enable and 110 enable and (
108 bool(self.targetDirectoryPicker.text()) and 111 self.remoteCheckBox.isChecked() or (
109 os.path.exists(self.targetDirectoryPicker.text()) 112 bool(self.targetDirectoryPicker.text()) and
113 os.path.exists(self.targetDirectoryPicker.text())
114 )
115 )
110 ) 116 )
111 117
112 enable = ( 118 enable = (
113 enable and 119 enable and
114 bool(self.pythonExecPicker.text()) and 120 bool(self.pythonExecPicker.text()) and (
115 os.access(self.pythonExecPicker.text(), os.X_OK) 121 self.remoteCheckBox.isChecked() or
122 os.access(self.pythonExecPicker.text(), os.X_OK)
123 )
116 ) 124 )
117 125
118 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable) 126 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
119 127
120 @pyqtSlot(str) 128 @pyqtSlot(str)
155 163
156 @pyqtSlot(bool) 164 @pyqtSlot(bool)
157 def on_globalCheckBox_toggled(self, checked): 165 def on_globalCheckBox_toggled(self, checked):
158 """ 166 """
159 Private slot handling a change of the global check box state. 167 Private slot handling a change of the global check box state.
168
169 @param checked state of the check box
170 @type bool
171 """
172 self.__updateOk()
173
174 @pyqtSlot(bool)
175 def on_remoteCheckBox_toggled(self, checked):
176 """
177 Private slot handling a change of the remote check box state.
160 178
161 @param checked state of the check box 179 @param checked state of the check box
162 @type bool 180 @type bool
163 """ 181 """
164 self.__updateOk() 182 self.__updateOk()
192 Public method to retrieve the entered data. 210 Public method to retrieve the entered data.
193 211
194 @return tuple containing the logical name, the directory, the 212 @return tuple containing the logical name, the directory, the
195 interpreter of the virtual environment, the Python variant, 213 interpreter of the virtual environment, the Python variant,
196 a flag indicating a global environment, a flag indicating an 214 a flag indicating a global environment, a flag indicating an
197 Anaconda environment and a string to be prepended to the PATH 215 Anaconda environment, aflag indicating a remotely accessed
198 environment variable 216 environment and a string to be prepended to the PATH environment
199 @rtype tuple of (str, str, str, int, bool,bool, str) 217 variable
218 @rtype tuple of (str, str, str, int, bool, bool, bool, str)
200 """ 219 """
201 return ( 220 return (
202 self.nameEdit.text(), 221 self.nameEdit.text(),
203 self.targetDirectoryPicker.text(), 222 self.targetDirectoryPicker.text(),
204 self.pythonExecPicker.text(), 223 self.pythonExecPicker.text(),
205 3 - self.variantComboBox.currentIndex(), 224 3 - self.variantComboBox.currentIndex(),
206 self.globalCheckBox.isChecked(), 225 self.globalCheckBox.isChecked(),
207 self.anacondaCheckBox.isChecked(), 226 self.anacondaCheckBox.isChecked(),
227 self.remoteCheckBox.isChecked(),
208 self.execPathEdit.text(), 228 self.execPathEdit.text(),
209 ) 229 )

eric ide

mercurial