E5Gui/E5TextInputDialog.py

changeset 6533
b7df503cb673
parent 6532
f253f0f9ea7f
child 6645
ad476851d7e0
equal deleted inserted replaced
6532:f253f0f9ea7f 6533:b7df503cb673
31 self.setMaximumWidth(600) 31 self.setMaximumWidth(600)
32 32
33 self.__layout = QVBoxLayout(self) 33 self.__layout = QVBoxLayout(self)
34 34
35 self.__label = QLabel(self) 35 self.__label = QLabel(self)
36 self.__label.setWordWrap(True)
37 self.__layout.addWidget(self.__label) 36 self.__layout.addWidget(self.__label)
38 37
39 self.__lineEdit = E5ClearableLineEdit(self) 38 self.__lineEdit = E5ClearableLineEdit(self)
40 self.__layout.addWidget(self.__lineEdit) 39 self.__layout.addWidget(self.__lineEdit)
41 40
91 90
92 @param text label text 91 @param text label text
93 @type str 92 @type str
94 """ 93 """
95 self.__label.setText(text) 94 self.__label.setText(text)
95
96 msh = self.minimumSizeHint()
97 labelSizeHint = self.__label.sizeHint()
98 self.resize(max(self.width(), msh.width(), labelSizeHint.width()),
99 msh.height())
96 100
97 def labelText(self): 101 def labelText(self):
98 """ 102 """
99 Public method to get the current label text. 103 Public method to get the current label text.
100 104
102 @rtype str 106 @rtype str
103 """ 107 """
104 return self.label.text() 108 return self.label.text()
105 109
106 110
107 def getText(parent, title, label, mode=QLineEdit.Normal, text=""): 111 def getText(parent, title, label, mode=QLineEdit.Normal, text="",
112 minimumWidth=300):
108 """ 113 """
109 Function to get create a dialog to enter some text and return it. 114 Function to get create a dialog to enter some text and return it.
110 115
111 @param parent reference to the parent widget 116 @param parent reference to the parent widget
112 @type QWidget 117 @type QWidget
116 @type str 121 @type str
117 @param mode echo mode of the line edit 122 @param mode echo mode of the line edit
118 @type QLineEdit.EchoMode 123 @type QLineEdit.EchoMode
119 @param text initial text of the line edit 124 @param text initial text of the line edit
120 @type str 125 @type str
126 @param minimumWidth minimum width of the dialog
127 @type int
121 @return tuple containing a flag indicating the dialog was accepted and the 128 @return tuple containing a flag indicating the dialog was accepted and the
122 entered text 129 entered text
123 @rtype tuple of (bool, str) 130 @rtype tuple of (bool, str)
124 """ 131 """
125 dlg = E5TextInputDialog(parent) 132 dlg = E5TextInputDialog(parent)
126 dlg.setWindowTitle(title) 133 dlg.setWindowTitle(title)
127 dlg.setLabelText(label) 134 dlg.setLabelText(label)
128 dlg.setTextEchoMode(mode) 135 dlg.setTextEchoMode(mode)
129 dlg.setTextValue(text) 136 dlg.setTextValue(text)
137 dlg.setMinimumWidth(minimumWidth)
138
130 if dlg.exec_() == QDialog.Accepted: 139 if dlg.exec_() == QDialog.Accepted:
131 return True, dlg.textValue() 140 return True, dlg.textValue()
132 else: 141 else:
133 return False, "" 142 return False, ""

eric ide

mercurial