eric7/E5Gui/E5MessageBox.py

branch
eric7
changeset 8318
962bce857696
parent 8312
800c432b34c8
equal deleted inserted replaced
8316:0c7a44af84bc 8318:962bce857696
5 5
6 """ 6 """
7 Module implementing QMessageBox replacements and more convenience function. 7 Module implementing QMessageBox replacements and more convenience function.
8 """ 8 """
9 9
10 from PyQt5.QtCore import Qt 10 from PyQt6.QtCore import Qt
11 from PyQt5.QtWidgets import QMessageBox, QApplication 11 from PyQt6.QtWidgets import QMessageBox, QApplication
12 12
13 ############################################################################### 13 ###############################################################################
14 ## Mappings to standard QMessageBox ## 14 ## Mappings to standard QMessageBox ##
15 ############################################################################### 15 ###############################################################################
16 16
19 Critical = QMessageBox.Icon.Critical 19 Critical = QMessageBox.Icon.Critical
20 Information = QMessageBox.Icon.Information 20 Information = QMessageBox.Icon.Information
21 Question = QMessageBox.Icon.Question 21 Question = QMessageBox.Icon.Question
22 Warning = QMessageBox.Icon.Warning # __IGNORE_WARNING_M131__ 22 Warning = QMessageBox.Icon.Warning # __IGNORE_WARNING_M131__
23 23
24 StandardButtons = QMessageBox.StandardButtons 24 ##StandardButtons = QMessageBox.StandardButtons
25 25 ##
26 # QMessageBox.StandardButton 26 # QMessageBox.StandardButton
27 Abort = QMessageBox.StandardButton.Abort 27 Abort = QMessageBox.StandardButton.Abort
28 Apply = QMessageBox.StandardButton.Apply 28 Apply = QMessageBox.StandardButton.Apply
29 Cancel = QMessageBox.StandardButton.Cancel 29 Cancel = QMessageBox.StandardButton.Cancel
30 Close = QMessageBox.StandardButton.Close 30 Close = QMessageBox.StandardButton.Close
244 if icon not in [Critical, Information, Question, Warning]: 244 if icon not in [Critical, Information, Question, Warning]:
245 raise ValueError("Bad value for 'icon' parameter.") 245 raise ValueError("Bad value for 'icon' parameter.")
246 246
247 res = __messageBox( 247 res = __messageBox(
248 parent, title, text, icon, 248 parent, title, text, icon,
249 QMessageBox.StandardButtons(QMessageBox.StandardButton.Yes | 249 QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No,
250 QMessageBox.StandardButton.No),
251 yesDefault and QMessageBox.StandardButton.Yes or 250 yesDefault and QMessageBox.StandardButton.Yes or
252 QMessageBox.StandardButton.No, 251 QMessageBox.StandardButton.No,
253 textFormat) 252 textFormat)
254 return res == QMessageBox.StandardButton.Yes 253 return res == QMessageBox.StandardButton.Yes
255 254
271 if icon not in [Critical, Information, Question, Warning]: 270 if icon not in [Critical, Information, Question, Warning]:
272 raise ValueError("Bad value for 'icon' parameter.") 271 raise ValueError("Bad value for 'icon' parameter.")
273 272
274 res = __messageBox( 273 res = __messageBox(
275 parent, title, text, icon, 274 parent, title, text, icon,
276 QMessageBox.StandardButtons(QMessageBox.StandardButton.Retry | 275 QMessageBox.StandardButton.Retry | QMessageBox.StandardButton.Abort,
277 QMessageBox.StandardButton.Abort),
278 QMessageBox.StandardButton.Retry, 276 QMessageBox.StandardButton.Retry,
279 textFormat) 277 textFormat)
280 return res == QMessageBox.StandardButton.Retry 278 return res == QMessageBox.StandardButton.Retry
281 279
282 280
293 @param textFormat format of the text (Qt.TextFormat) 291 @param textFormat format of the text (Qt.TextFormat)
294 @return flag indicating that it is ok to clear the data (boolean) 292 @return flag indicating that it is ok to clear the data (boolean)
295 """ 293 """
296 res = __messageBox( 294 res = __messageBox(
297 parent, title, text, QMessageBox.Icon.Warning, 295 parent, title, text, QMessageBox.Icon.Warning,
298 QMessageBox.StandardButtons( 296 (QMessageBox.StandardButton.Abort |
299 QMessageBox.StandardButton.Abort | 297 QMessageBox.StandardButton.Discard |
300 QMessageBox.StandardButton.Discard | 298 QMessageBox.StandardButton.Save),
301 QMessageBox.StandardButton.Save),
302 QMessageBox.StandardButton.Save, 299 QMessageBox.StandardButton.Save,
303 textFormat) 300 textFormat)
304 if res == QMessageBox.StandardButton.Abort: 301 if res == QMessageBox.StandardButton.Abort:
305 return False 302 return False
306 if res == QMessageBox.StandardButton.Save: 303 if res == QMessageBox.StandardButton.Save:

eric ide

mercurial