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 |
75 " environment variable. Use '{0}' as the separator.").format( |
77 " environment variable. Use '{0}' as the separator.").format( |
76 os.pathsep) |
78 os.pathsep) |
77 ) |
79 ) |
78 |
80 |
79 self.nameEdit.setText(venvName) |
81 self.nameEdit.setText(venvName) |
80 self.targetDirectoryPicker.setText(venvDirectory) |
82 self.targetDirectoryPicker.setText(venvDirectory, |
81 self.pythonExecPicker.setText(venvInterpreter) |
83 toNative=not isRemote) |
|
84 self.pythonExecPicker.setText(venvInterpreter, |
|
85 toNative=not isRemote) |
82 self.variantComboBox.setCurrentIndex(3 - venvVariant) |
86 self.variantComboBox.setCurrentIndex(3 - venvVariant) |
83 self.globalCheckBox.setChecked(isGlobal) |
87 self.globalCheckBox.setChecked(isGlobal) |
84 self.anacondaCheckBox.setChecked(isConda) |
88 self.anacondaCheckBox.setChecked(isConda) |
|
89 self.remoteCheckBox.setChecked(isRemote) |
85 self.execPathEdit.setText(execPath) |
90 self.execPathEdit.setText(execPath) |
86 |
91 |
87 self.__updateOk() |
92 self.__updateOk() |
88 |
93 |
89 def __updateOk(self): |
94 def __updateOk(self): |
102 self.__manager.isUnique(self.nameEdit.text()) |
107 self.__manager.isUnique(self.nameEdit.text()) |
103 ) |
108 ) |
104 |
109 |
105 if not self.globalCheckBox.isChecked(): |
110 if not self.globalCheckBox.isChecked(): |
106 enable = ( |
111 enable = ( |
107 enable and |
112 enable and ( |
108 bool(self.targetDirectoryPicker.text()) and |
113 self.remoteCheckBox.isChecked() or ( |
109 os.path.exists(self.targetDirectoryPicker.text()) |
114 bool(self.targetDirectoryPicker.text()) and |
|
115 os.path.exists(self.targetDirectoryPicker.text()) |
|
116 ) |
|
117 ) |
110 ) |
118 ) |
111 |
119 |
112 enable = ( |
120 enable = ( |
113 enable and |
121 enable and |
114 bool(self.pythonExecPicker.text()) and |
122 bool(self.pythonExecPicker.text()) and ( |
115 os.access(self.pythonExecPicker.text(), os.X_OK) |
123 self.remoteCheckBox.isChecked() or |
|
124 os.access(self.pythonExecPicker.text(), os.X_OK) |
|
125 ) |
116 ) |
126 ) |
117 |
127 |
118 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable) |
128 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable) |
119 |
129 |
120 @pyqtSlot(str) |
130 @pyqtSlot(str) |
155 |
165 |
156 @pyqtSlot(bool) |
166 @pyqtSlot(bool) |
157 def on_globalCheckBox_toggled(self, checked): |
167 def on_globalCheckBox_toggled(self, checked): |
158 """ |
168 """ |
159 Private slot handling a change of the global check box state. |
169 Private slot handling a change of the global check box state. |
|
170 |
|
171 @param checked state of the check box |
|
172 @type bool |
|
173 """ |
|
174 self.__updateOk() |
|
175 |
|
176 @pyqtSlot(bool) |
|
177 def on_remoteCheckBox_toggled(self, checked): |
|
178 """ |
|
179 Private slot handling a change of the remote check box state. |
160 |
180 |
161 @param checked state of the check box |
181 @param checked state of the check box |
162 @type bool |
182 @type bool |
163 """ |
183 """ |
164 self.__updateOk() |
184 self.__updateOk() |
192 Public method to retrieve the entered data. |
212 Public method to retrieve the entered data. |
193 |
213 |
194 @return tuple containing the logical name, the directory, the |
214 @return tuple containing the logical name, the directory, the |
195 interpreter of the virtual environment, the Python variant, |
215 interpreter of the virtual environment, the Python variant, |
196 a flag indicating a global environment, a flag indicating an |
216 a flag indicating a global environment, a flag indicating an |
197 Anaconda environment and a string to be prepended to the PATH |
217 Anaconda environment, aflag indicating a remotely accessed |
198 environment variable |
218 environment and a string to be prepended to the PATH environment |
199 @rtype tuple of (str, str, str, int, bool,bool, str) |
219 variable |
200 """ |
220 @rtype tuple of (str, str, str, int, bool, bool, bool, str) |
|
221 """ |
|
222 nativePaths = not self.remoteCheckBox.isChecked() |
201 return ( |
223 return ( |
202 self.nameEdit.text(), |
224 self.nameEdit.text(), |
203 self.targetDirectoryPicker.text(), |
225 self.targetDirectoryPicker.text(toNative=nativePaths), |
204 self.pythonExecPicker.text(), |
226 self.pythonExecPicker.text(toNative=nativePaths), |
205 3 - self.variantComboBox.currentIndex(), |
227 3 - self.variantComboBox.currentIndex(), |
206 self.globalCheckBox.isChecked(), |
228 self.globalCheckBox.isChecked(), |
207 self.anacondaCheckBox.isChecked(), |
229 self.anacondaCheckBox.isChecked(), |
|
230 self.remoteCheckBox.isChecked(), |
208 self.execPathEdit.text(), |
231 self.execPathEdit.text(), |
209 ) |
232 ) |