E5Gui/E5MessageBox.py

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

eric ide

mercurial