17 class VirtualenvNameDialog(QDialog, Ui_VirtualenvNameDialog): |
17 class VirtualenvNameDialog(QDialog, Ui_VirtualenvNameDialog): |
18 """ |
18 """ |
19 Class implementing a dialog to enter the logical name for a new virtual |
19 Class implementing a dialog to enter the logical name for a new virtual |
20 environment. |
20 environment. |
21 """ |
21 """ |
|
22 |
22 def __init__(self, environments, currentName, parent=None): |
23 def __init__(self, environments, currentName, parent=None): |
23 """ |
24 """ |
24 Constructor |
25 Constructor |
25 |
26 |
26 @param environments list of environment names to be shown |
27 @param environments list of environment names to be shown |
27 @type list of str |
28 @type list of str |
28 @param currentName name to be shown in the name edit |
29 @param currentName name to be shown in the name edit |
29 @type str |
30 @type str |
30 @param parent reference to the parent widget |
31 @param parent reference to the parent widget |
31 @type QWidget |
32 @type QWidget |
32 """ |
33 """ |
33 super().__init__(parent) |
34 super().__init__(parent) |
34 self.setupUi(self) |
35 self.setupUi(self) |
35 |
36 |
36 self.envsList.addItems(environments) |
37 self.envsList.addItems(environments) |
37 self.nameEdit.setText(currentName) |
38 self.nameEdit.setText(currentName) |
38 |
39 |
39 self.nameEdit.setFocus(Qt.FocusReason.OtherFocusReason) |
40 self.nameEdit.setFocus(Qt.FocusReason.OtherFocusReason) |
40 self.nameEdit.selectAll() |
41 self.nameEdit.selectAll() |
41 |
42 |
42 @pyqtSlot(str) |
43 @pyqtSlot(str) |
43 def on_nameEdit_textChanged(self, txt): |
44 def on_nameEdit_textChanged(self, txt): |
44 """ |
45 """ |
45 Private slot to handle a change of the environment name. |
46 Private slot to handle a change of the environment name. |
46 |
47 |
47 @param txt contens of the name edit |
48 @param txt contens of the name edit |
48 @type str |
49 @type str |
49 """ |
50 """ |
50 items = self.envsList.findItems(txt, Qt.MatchFlag.MatchExactly) |
51 items = self.envsList.findItems(txt, Qt.MatchFlag.MatchExactly) |
51 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
52 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
52 bool(txt) and len(items) == 0) |
53 bool(txt) and len(items) == 0 |
53 |
54 ) |
|
55 |
54 def getName(self): |
56 def getName(self): |
55 """ |
57 """ |
56 Public method to get the entered name. |
58 Public method to get the entered name. |
57 |
59 |
58 @return name for the environment |
60 @return name for the environment |
59 @rtype str |
61 @rtype str |
60 """ |
62 """ |
61 return self.nameEdit.text() |
63 return self.nameEdit.text() |