VirtualEnv/VirtualenvAddEditDialog.py

changeset 6362
ec32d1d7f525
parent 6349
17b3c75913de
child 6576
ea60ea85067a
equal deleted inserted replaced
6361:53f6bd7fb238 6362:ec32d1d7f525
25 class VirtualenvAddEditDialog(QDialog, Ui_VirtualenvAddEditDialog): 25 class VirtualenvAddEditDialog(QDialog, Ui_VirtualenvAddEditDialog):
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, parent=None): 30 venvInterpreter="", venvVariant=3, isGlobal=False,
31 parent=None):
31 """ 32 """
32 Constructor 33 Constructor
33 34
34 @param manager reference to the virtual environment manager 35 @param manager reference to the virtual environment manager
35 @type VirtualenvManager 36 @type VirtualenvManager
39 @type str 40 @type str
40 @param venvInterpreter Python interpreter of the virtual environment 41 @param venvInterpreter Python interpreter of the virtual environment
41 @type str 42 @type str
42 @param venvVariant Python variant of the virtual environment 43 @param venvVariant Python variant of the virtual environment
43 @type int 44 @type int
45 @param isGlobal flag indicating a global environment
46 @type bool
44 @param parent reference to the parent widget 47 @param parent reference to the parent widget
45 @type QWidget 48 @type QWidget
46 """ 49 """
47 super(VirtualenvAddEditDialog, self).__init__(parent) 50 super(VirtualenvAddEditDialog, self).__init__(parent)
48 self.setupUi(self) 51 self.setupUi(self)
64 67
65 self.nameEdit.setText(venvName) 68 self.nameEdit.setText(venvName)
66 self.targetDirectoryPicker.setText(venvDirectory) 69 self.targetDirectoryPicker.setText(venvDirectory)
67 self.pythonExecPicker.setText(venvInterpreter) 70 self.pythonExecPicker.setText(venvInterpreter)
68 self.variantComboBox.setCurrentIndex(3 - venvVariant) 71 self.variantComboBox.setCurrentIndex(3 - venvVariant)
69 self.globalCheckBox.setChecked(self.__editMode and 72 self.globalCheckBox.setChecked(isGlobal)
70 not bool(venvDirectory))
71 73
72 self.__updateOk() 74 self.__updateOk()
73 75
74 def __updateOk(self): 76 def __updateOk(self):
75 """ 77 """
144 Private slot handling a change of the global check box state. 146 Private slot handling a change of the global check box state.
145 147
146 @param checked state of the check box 148 @param checked state of the check box
147 @type bool 149 @type bool
148 """ 150 """
149 self.targetDirectoryPicker.setEnabled(not checked)
150
151 self.__updateOk() 151 self.__updateOk()
152 152
153 def getData(self): 153 def getData(self):
154 """ 154 """
155 Public method to retrieve the entered data. 155 Public method to retrieve the entered data.
156 156
157 @return tuple containing the logical name, the directory, the 157 @return tuple containing the logical name, the directory, the
158 interpreter of the virtual environment and the Python variant 158 interpreter of the virtual environment, the Python variant
159 @rtype tuple of (str, str, str, int) 159 and a flag indicating a global environment
160 @rtype tuple of (str, str, str, int, bool)
160 """ 161 """
161 if self.globalCheckBox.isChecked(): 162 return (
162 return ( 163 self.nameEdit.text(),
163 self.nameEdit.text(), 164 self.targetDirectoryPicker.text(),
164 "", 165 self.pythonExecPicker.text(),
165 self.pythonExecPicker.text(), 166 3 - self.variantComboBox.currentIndex(),
166 3 - self.variantComboBox.currentIndex(), 167 self.globalCheckBox.isChecked(),
167 ) 168 )
168 else:
169 return (
170 self.nameEdit.text(),
171 self.targetDirectoryPicker.text(),
172 self.pythonExecPicker.text(),
173 3 - self.variantComboBox.currentIndex(),
174 )

eric ide

mercurial