17 |
17 |
18 class CondaNewEnvironmentDataDialog(QDialog, Ui_CondaNewEnvironmentDataDialog): |
18 class CondaNewEnvironmentDataDialog(QDialog, Ui_CondaNewEnvironmentDataDialog): |
19 """ |
19 """ |
20 Class implementing a dialog to enter data for a new conda environment. |
20 Class implementing a dialog to enter data for a new conda environment. |
21 """ |
21 """ |
|
22 |
22 def __init__(self, title, showRequirements, parent=None): |
23 def __init__(self, title, showRequirements, parent=None): |
23 """ |
24 """ |
24 Constructor |
25 Constructor |
25 |
26 |
26 @param title tirle of the dialog |
27 @param title tirle of the dialog |
27 @type str |
28 @type str |
28 @param showRequirements flag indicating to show the requirements |
29 @param showRequirements flag indicating to show the requirements |
29 file input widget |
30 file input widget |
30 @type bool |
31 @type bool |
31 @param parent reference to the parent widget |
32 @param parent reference to the parent widget |
32 @type QWidget |
33 @type QWidget |
33 """ |
34 """ |
34 super().__init__(parent) |
35 super().__init__(parent) |
35 self.setupUi(self) |
36 self.setupUi(self) |
36 |
37 |
37 self.setWindowTitle(title) |
38 self.setWindowTitle(title) |
38 |
39 |
39 self.__requirementsMode = showRequirements |
40 self.__requirementsMode = showRequirements |
40 |
41 |
41 self.requirementsFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
42 self.requirementsFilePicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
42 self.requirementsFilePicker.setFilters( |
43 self.requirementsFilePicker.setFilters( |
43 self.tr("Text Files (*.txt);;All Files (*)")) |
44 self.tr("Text Files (*.txt);;All Files (*)") |
44 |
45 ) |
|
46 |
45 self.requirementsLabel.setVisible(showRequirements) |
47 self.requirementsLabel.setVisible(showRequirements) |
46 self.requirementsFilePicker.setVisible(showRequirements) |
48 self.requirementsFilePicker.setVisible(showRequirements) |
47 |
49 |
48 self.__updateOK() |
50 self.__updateOK() |
49 |
51 |
50 msh = self.minimumSizeHint() |
52 msh = self.minimumSizeHint() |
51 self.resize(max(self.width(), msh.width()), msh.height()) |
53 self.resize(max(self.width(), msh.width()), msh.height()) |
52 |
54 |
53 def __updateOK(self): |
55 def __updateOK(self): |
54 """ |
56 """ |
55 Private method to update the enabled state of the OK button. |
57 Private method to update the enabled state of the OK button. |
56 """ |
58 """ |
57 enable = bool(self.nameEdit.text()) and bool(self.condaNameEdit.text()) |
59 enable = bool(self.nameEdit.text()) and bool(self.condaNameEdit.text()) |
58 if self.__requirementsMode: |
60 if self.__requirementsMode: |
59 enable &= bool(self.requirementsFilePicker.text()) |
61 enable &= bool(self.requirementsFilePicker.text()) |
60 |
62 |
61 self.buttonBox.button( |
63 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable) |
62 QDialogButtonBox.StandardButton.Ok).setEnabled(enable) |
64 |
63 |
|
64 @pyqtSlot(str) |
65 @pyqtSlot(str) |
65 def on_nameEdit_textChanged(self, txt): |
66 def on_nameEdit_textChanged(self, txt): |
66 """ |
67 """ |
67 Private slot to handle changes of the logical name. |
68 Private slot to handle changes of the logical name. |
68 |
69 |
69 @param txt current text of the logical name entry |
70 @param txt current text of the logical name entry |
70 @type str |
71 @type str |
71 """ |
72 """ |
72 self.__updateOK() |
73 self.__updateOK() |
73 |
74 |
74 @pyqtSlot(str) |
75 @pyqtSlot(str) |
75 def on_condaNameEdit_textChanged(self, txt): |
76 def on_condaNameEdit_textChanged(self, txt): |
76 """ |
77 """ |
77 Private slot to handle changes of the conda name. |
78 Private slot to handle changes of the conda name. |
78 |
79 |
79 @param txt current text of the conda name entry |
80 @param txt current text of the conda name entry |
80 @type str |
81 @type str |
81 """ |
82 """ |
82 self.__updateOK() |
83 self.__updateOK() |
83 |
84 |
84 @pyqtSlot(str) |
85 @pyqtSlot(str) |
85 def on_requirementsFilePicker_textChanged(self, txt): |
86 def on_requirementsFilePicker_textChanged(self, txt): |
86 """ |
87 """ |
87 Private slot to handle changes of the requirements file name. |
88 Private slot to handle changes of the requirements file name. |
88 |
89 |
89 @param txt current text of the requirements file name entry |
90 @param txt current text of the requirements file name entry |
90 @type str |
91 @type str |
91 """ |
92 """ |
92 self.__updateOK() |
93 self.__updateOK() |
93 |
94 |
94 def getData(self): |
95 def getData(self): |
95 """ |
96 """ |
96 Public method to get the entered data. |
97 Public method to get the entered data. |
97 |
98 |
98 @return tuple with the logical name of the new environment, the conda |
99 @return tuple with the logical name of the new environment, the conda |
99 name and the requirements file name |
100 name and the requirements file name |
100 @rtype tuple of (str, str, str) |
101 @rtype tuple of (str, str, str) |
101 """ |
102 """ |
102 requirementsFile = ( |
103 requirementsFile = ( |
103 self.requirementsFilePicker.text() |
104 self.requirementsFilePicker.text() if self.__requirementsMode else "" |
104 if self.__requirementsMode else |
|
105 "" |
|
106 ) |
105 ) |
107 |
106 |
108 return ( |
107 return (self.nameEdit.text(), self.condaNameEdit.text(), requirementsFile) |
109 self.nameEdit.text(), |
|
110 self.condaNameEdit.text(), |
|
111 requirementsFile |
|
112 ) |
|