ProjectDjangoTagsMenu/DjangoTagInputDialog.py

changeset 52
c264091162a2
parent 51
29c461f7bea0
child 55
5390ef66c327
equal deleted inserted replaced
51:29c461f7bea0 52:c264091162a2
25 @param defaults list of default values for the entry fields (list 25 @param defaults list of default values for the entry fields (list
26 of string) 26 of string)
27 @param parent reference to the parent widget (QWidget) 27 @param parent reference to the parent widget (QWidget)
28 @exception RuntimeError raised to signal too many labels were given 28 @exception RuntimeError raised to signal too many labels were given
29 """ 29 """
30 super(DjangoTagInputDialog, self).__init__(parent) 30 super().__init__(parent)
31 31
32 if len(labels) == 0 or len(labels) > 5: 32 if len(labels) == 0 or len(labels) > 5:
33 raise RuntimeError( 33 raise RuntimeError(
34 "Illegal number of labels given (max. 5 allowed)") 34 "Illegal number of labels given (max. 5 allowed)")
35 35
36 self.__inputs = [] 36 self.__inputs = []
37 37
38 self.__topLayout = QVBoxLayout(self) 38 self.__topLayout = QVBoxLayout(self)
39 index = 0 39 for index, label in enumerate(labels):
40 for label in labels:
41 self.__topLayout.addWidget(QLabel(label, self)) 40 self.__topLayout.addWidget(QLabel(label, self))
42 entry = E5ClearableLineEdit(self) 41 entry = E5ClearableLineEdit(self)
43 if defaults and index < len(defaults): 42 if defaults and index < len(defaults):
44 entry.setText(defaults[index]) 43 entry.setText(defaults[index])
45 self.__inputs.append(entry) 44 self.__inputs.append(entry)
46 self.__topLayout.addWidget(entry) 45 self.__topLayout.addWidget(entry)
47 index += 1
48 self.__buttonBox = QDialogButtonBox( 46 self.__buttonBox = QDialogButtonBox(
49 QDialogButtonBox.Ok | QDialogButtonBox.Cancel, 47 QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
50 Qt.Horizontal, self) 48 Qt.Horizontal, self)
51 self.__topLayout.addWidget(self.__buttonBox) 49 self.__topLayout.addWidget(self.__buttonBox)
52 50

eric ide

mercurial