E5Gui/E5MessageBox.py

changeset 2990
583beaf0b4b8
parent 2302
f29e9405c851
child 3022
57179e4cdadd
child 3057
10516539f238
equal deleted inserted replaced
2989:7efa8b8b6903 2990:583beaf0b4b8
8 """ 8 """
9 9
10 from PyQt4.QtCore import Qt 10 from PyQt4.QtCore import Qt
11 from PyQt4.QtGui import QMessageBox, QApplication 11 from PyQt4.QtGui import QMessageBox, QApplication
12 12
13 ################################################################################ 13 ###############################################################################
14 ## Mappings to standard QMessageBox ## 14 ## Mappings to standard QMessageBox ##
15 ################################################################################ 15 ###############################################################################
16 16
17 # QMessageBox.Icon 17 # QMessageBox.Icon
18 NoIcon = QMessageBox.NoIcon 18 NoIcon = QMessageBox.NoIcon
19 Critical = QMessageBox.Critical 19 Critical = QMessageBox.Critical
20 Information = QMessageBox.Information 20 Information = QMessageBox.Information
54 NoRole = QMessageBox.NoRole 54 NoRole = QMessageBox.NoRole
55 RejectRole = QMessageBox.RejectRole 55 RejectRole = QMessageBox.RejectRole
56 ResetRole = QMessageBox.ResetRole 56 ResetRole = QMessageBox.ResetRole
57 YesRole = QMessageBox.YesRole 57 YesRole = QMessageBox.YesRole
58 58
59 ################################################################################ 59 ###############################################################################
60 ## Replacement for the QMessageBox class ## 60 ## Replacement for the QMessageBox class ##
61 ################################################################################ 61 ###############################################################################
62 62
63 63
64 class E5MessageBox(QMessageBox): 64 class E5MessageBox(QMessageBox):
65 """ 65 """
66 Class implementing a replacement for QMessageBox. 66 Class implementing a replacement for QMessageBox.
94 self.setWindowTitle("{0} - {1}".format( 94 self.setWindowTitle("{0} - {1}".format(
95 QApplication.applicationName(), title)) 95 QApplication.applicationName(), title))
96 self.setText(text) 96 self.setText(text)
97 self.setStandardButtons(buttons) 97 self.setStandardButtons(buttons)
98 98
99 ################################################################################ 99 ###############################################################################
100 ## Replacements for QMessageBox static methods ## 100 ## Replacements for QMessageBox static methods ##
101 ################################################################################ 101 ###############################################################################
102 102
103 103
104 def __messageBox(parent, title, text, icon, 104 def __messageBox(parent, title, text, icon,
105 buttons=QMessageBox.Ok, defaultButton=QMessageBox.NoButton, 105 buttons=QMessageBox.Ok, defaultButton=QMessageBox.NoButton,
106 textFormat=Qt.AutoText): 106 textFormat=Qt.AutoText):
213 @return button pressed by the user (QMessageBox.StandardButton) 213 @return button pressed by the user (QMessageBox.StandardButton)
214 """ 214 """
215 return __messageBox(parent, title, text, QMessageBox.Warning, 215 return __messageBox(parent, title, text, QMessageBox.Warning,
216 buttons, defaultButton) 216 buttons, defaultButton)
217 217
218 ################################################################################ 218 ###############################################################################
219 ## Additional convenience functions ## 219 ## Additional convenience functions ##
220 ################################################################################ 220 ###############################################################################
221 221
222 222
223 def yesNo(parent, title, text, icon=Question, yesDefault=False, textFormat=Qt.AutoText): 223 def yesNo(parent, title, text, icon=Question, yesDefault=False,
224 textFormat=Qt.AutoText):
224 """ 225 """
225 Function to show a model yes/no message box. 226 Function to show a model yes/no message box.
226 227
227 @param parent parent widget of the message box (QWidget) 228 @param parent parent widget of the message box (QWidget)
228 @param title caption of the message box (string) 229 @param title caption of the message box (string)
229 @param text text to be shown by the message box (string) 230 @param text text to be shown by the message box (string)
230 @keyparam icon icon for the dialog (Critical, Information, Question or Warning) 231 @keyparam icon icon for the dialog (Critical, Information, Question or
231 @keyparam yesDefault flag indicating that the Yes button should be the default 232 Warning)
232 button (boolean) 233 @keyparam yesDefault flag indicating that the Yes button should be the
234 default button (boolean)
233 @param textFormat format of the text (Qt.TextFormat) 235 @param textFormat format of the text (Qt.TextFormat)
234 @return flag indicating the selection of the Yes button (boolean) 236 @return flag indicating the selection of the Yes button (boolean)
235 """ 237 """
236 assert icon in [Critical, Information, Question, Warning] 238 assert icon in [Critical, Information, Question, Warning]
237 239
247 Function to show a model abort/retry message box. 249 Function to show a model abort/retry message box.
248 250
249 @param parent parent widget of the message box (QWidget) 251 @param parent parent widget of the message box (QWidget)
250 @param title caption of the message box (string) 252 @param title caption of the message box (string)
251 @param text text to be shown by the message box (string) 253 @param text text to be shown by the message box (string)
252 @keyparam icon icon for the dialog (Critical, Information, Question or Warning) 254 @keyparam icon icon for the dialog (Critical, Information, Question or
255 Warning)
253 @param textFormat format of the text (Qt.TextFormat) 256 @param textFormat format of the text (Qt.TextFormat)
254 @return flag indicating the selection of the Retry button (boolean) 257 @return flag indicating the selection of the Retry button (boolean)
255 """ 258 """
256 assert icon in [Critical, Information, Question, Warning] 259 assert icon in [Critical, Information, Question, Warning]
257 260

eric ide

mercurial