ProjectDjangoTagsMenu/DjangoTagInputDialog.py

changeset 47
825bf5861f89
parent 44
3ea572ed13b6
child 49
ef6c805ae218
equal deleted inserted replaced
46:1e62de075091 47:825bf5861f89
4 # 4 #
5 5
6 """ 6 """
7 Module implementing a dialog to enter data for the creation of a tag. 7 Module implementing a dialog to enter data for the creation of a tag.
8 """ 8 """
9
10 from __future__ import unicode_literals
11 9
12 from PyQt5.QtCore import Qt 10 from PyQt5.QtCore import Qt
13 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel 11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel
14 12
15 from E5Gui.E5LineEdit import E5ClearableLineEdit 13 from E5Gui.E5LineEdit import E5ClearableLineEdit
25 23
26 @param labels list of labels for the entry fields (list of string) 24 @param labels list of labels for the entry fields (list of string)
27 @param defaults list of default values for the entry fields (list 25 @param defaults list of default values for the entry fields (list
28 of string) 26 of string)
29 @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
30 """ 29 """
31 super(DjangoTagInputDialog, self).__init__(parent) 30 super(DjangoTagInputDialog, self).__init__(parent)
32 31
33 assert 0 < len(labels) < 6 # max 5 entries allowed 32 if len(labels) == 0 or len(labels) > 5:
33 raise RuntimeError(
34 "Illegal number of labels given (max. 5 allowed)")
35
34 self.__inputs = [] 36 self.__inputs = []
35 37
36 self.__topLayout = QVBoxLayout(self) 38 self.__topLayout = QVBoxLayout(self)
37 index = 0 39 index = 0
38 for label in labels: 40 for label in labels:
86 dlg = DjangoTagInputDialog(labels, defaults, parent) 88 dlg = DjangoTagInputDialog(labels, defaults, parent)
87 dlg.setWindowTitle(title) 89 dlg.setWindowTitle(title)
88 if dlg.exec_() == QDialog.Accepted: 90 if dlg.exec_() == QDialog.Accepted:
89 return dlg.getData(), True 91 return dlg.getData(), True
90 else: 92 else:
91 return tuple(), False 93 return (), False

eric ide

mercurial