E5Gui/E5MessageBox.py

Fri, 11 Mar 2011 16:51:57 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 11 Mar 2011 16:51:57 +0100
changeset 945
8cd4d08fa9f6
parent 791
9ec2ac20e54e
child 1131
7781e396c903
permissions
-rw-r--r--

Made code mostly PEP 8 compliant (except all whitespace and line length).

536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
791
9ec2ac20e54e Updated copyright notice.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 591
diff changeset
3 # Copyright (c) 2010 - 2011 Detlev Offenbach <detlev@die-offenbachs.de>
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing QMessageBox replacements and more convenience function.
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt4.QtCore import Qt
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt4.QtGui import QMessageBox, QApplication
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
13 ################################################################################
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
14 ## Mappings to standard QMessageBox ##
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
15 ################################################################################
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
16
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
17 # QMessageBox.Icon
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
18 Critical = QMessageBox.Critical
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
19 Information = QMessageBox.Information
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
20 Question = QMessageBox.Question
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
21 Warning = QMessageBox.Warning
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
22
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
23 StandardButtons = QMessageBox.StandardButtons
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
24
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
25 # QMessageBox.StandardButton
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
26 Abort = QMessageBox.Abort
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
27 Apply = QMessageBox.Apply
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
28 Cancel = QMessageBox.Cancel
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
29 Close = QMessageBox.Close
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
30 Discard = QMessageBox.Discard
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
31 Help = QMessageBox.Help
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
32 Ignore = QMessageBox.Ignore
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
33 No = QMessageBox.No
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
34 NoToAll = QMessageBox.NoToAll
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
35 Ok = QMessageBox.Ok
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
36 Open = QMessageBox.Open
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
37 Reset = QMessageBox.Reset
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
38 RestoreDefaults = QMessageBox.RestoreDefaults
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
39 Retry = QMessageBox.Retry
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
40 Save = QMessageBox.Save
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
41 SaveAll = QMessageBox.SaveAll
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
42 Yes = QMessageBox.Yes
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
43 YesToAll = QMessageBox.YesToAll
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
44 NoButton = QMessageBox.NoButton
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
45
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
46 # QMessageBox.ButtonRole
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
47 AcceptRole = QMessageBox.AcceptRole
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
48 ActionRole = QMessageBox.ActionRole
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
49 ApplyRole = QMessageBox.ApplyRole
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
50 DestructiveRole = QMessageBox.DestructiveRole
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
51 InvalidRole = QMessageBox.InvalidRole
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
52 HelpRole = QMessageBox.HelpRole
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
53 NoRole = QMessageBox.NoRole
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
54 RejectRole = QMessageBox.RejectRole
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
55 ResetRole = QMessageBox.ResetRole
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
56 YesRole = QMessageBox.YesRole
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
57
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
58 ################################################################################
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
59 ## Replacement for the QMessageBox class ##
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
60 ################################################################################
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
61
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
62
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
63 class E5MessageBox(QMessageBox):
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
64 """
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
65 Class implementing a replacement for QMessageBox.
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
66 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
67 def __init__(self, icon, title, text, modal=False,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
68 buttons=QMessageBox.StandardButtons(QMessageBox.NoButton),
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
69 parent=None):
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
70 """
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
71 Constructor
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
72
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
73 @param icon type of icon to be shown (QMessageBox.Icon)
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
74 @param title caption of the message box (string)
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
75 @param text text to be shown by the message box (string)
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
76 @keyparam modal flag indicating a modal dialog (boolean)
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
77 @keyparam buttons set of standard buttons to generate (StandardButtons)
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
78 @keyparam parent parent widget of the message box (QWidget)
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
79 """
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
80 QMessageBox.__init__(self, parent)
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
81 self.setIcon(icon)
588
573767cf6bde Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
82 if modal:
573767cf6bde Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
83 if parent is not None:
573767cf6bde Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
84 self.setWindowModality(Qt.WindowModal)
573767cf6bde Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
85 else:
573767cf6bde Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
86 self.setWindowModality(Qt.ApplicationModal)
573767cf6bde Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
87 else:
573767cf6bde Fixed an issue in E5MessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 564
diff changeset
88 self.setWindowModality(Qt.NonModal)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
89 if title == "":
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
90 self.setWindowTitle("{0}".format(
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
91 QApplication.applicationName()))
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
92 else:
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
93 self.setWindowTitle("{0} - {1}".format(
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
94 QApplication.applicationName(), title))
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
95 self.setText(text)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
96 self.setStandardButtons(buttons)
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
97
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
98 ################################################################################
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
99 ## Replacements for QMessageBox static methods ##
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
100 ################################################################################
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
101
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
102
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
103 def __messageBox(parent, title, text, icon,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
104 buttons=QMessageBox.Ok, defaultButton=QMessageBox.NoButton):
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 """
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
106 Private module function to show a modal message box.
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
108 @param parent parent widget of the message box (QWidget)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
109 @param title caption of the message box (string)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
110 @param text text to be shown by the message box (string)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
111 @param icon type of icon to be shown (QMessageBox.Icon)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
112 @param buttons flags indicating which buttons to show
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 (QMessageBox.StandardButtons)
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114 @param defaultButton flag indicating the default button
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
115 (QMessageBox.StandardButton)
562
8bf0dbc1ca6a Added a wizard for the eric5 message box (E5MessageBox).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
116 @return button pressed by the user (QMessageBox.StandardButton)
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117 """
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
118 messageBox = QMessageBox(parent)
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
119 messageBox.setIcon(icon)
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 if parent is not None:
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 messageBox.setWindowModality(Qt.WindowModal)
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
122 if title == "":
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
123 messageBox.setWindowTitle("{0}".format(
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
124 QApplication.applicationName()))
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
125 else:
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
126 messageBox.setWindowTitle("{0} - {1}".format(
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 562
diff changeset
127 QApplication.applicationName(), title))
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 messageBox.setText(text)
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129 messageBox.setStandardButtons(buttons)
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 messageBox.setDefaultButton(defaultButton)
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 messageBox.exec_()
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 clickedButton = messageBox.clickedButton()
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 if clickedButton is None:
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 return QMessageBox.NoButton
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 else:
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 return messageBox.standardButton(clickedButton)
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
137
545
1538031b5175 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
138 # the about functions are here for consistancy
1538031b5175 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
139 about = QMessageBox.about
1538031b5175 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
140 aboutQt = QMessageBox.aboutQt
1538031b5175 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 541
diff changeset
141
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
142
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
143 def critical(parent, title, text,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
144 buttons=QMessageBox.Ok, defaultButton=QMessageBox.NoButton):
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
145 """
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
146 Function to show a modal critical message box.
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
147
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
148 @param parent parent widget of the message box (QWidget)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
149 @param title caption of the message box (string)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
150 @param text text to be shown by the message box (string)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
151 @param buttons flags indicating which buttons to show
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
152 (QMessageBox.StandardButtons)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
153 @param defaultButton flag indicating the default button
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
154 (QMessageBox.StandardButton)
562
8bf0dbc1ca6a Added a wizard for the eric5 message box (E5MessageBox).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
155 @return button pressed by the user (QMessageBox.StandardButton)
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
156 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
157 return __messageBox(parent, title, text, QMessageBox.Critical,
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
158 buttons, defaultButton)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
159
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
160
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
161 def information(parent, title, text,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
162 buttons=QMessageBox.Ok, defaultButton=QMessageBox.NoButton):
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
163 """
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
164 Function to show a modal information message box.
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
165
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
166 @param parent parent widget of the message box (QWidget)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
167 @param title caption of the message box (string)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
168 @param text text to be shown by the message box (string)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
169 @param buttons flags indicating which buttons to show
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
170 (QMessageBox.StandardButtons)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
171 @param defaultButton flag indicating the default button
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
172 (QMessageBox.StandardButton)
562
8bf0dbc1ca6a Added a wizard for the eric5 message box (E5MessageBox).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
173 @return button pressed by the user (QMessageBox.StandardButton)
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
174 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
175 return __messageBox(parent, title, text, QMessageBox.Information,
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
176 buttons, defaultButton)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
177
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
178
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
179 def question(parent, title, text,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
180 buttons=QMessageBox.Ok, defaultButton=QMessageBox.NoButton):
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
181 """
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
182 Function to show a modal question message box.
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
183
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
184 @param parent parent widget of the message box (QWidget)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
185 @param title caption of the message box (string)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
186 @param text text to be shown by the message box (string)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
187 @param buttons flags indicating which buttons to show
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
188 (QMessageBox.StandardButtons)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
189 @param defaultButton flag indicating the default button
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
190 (QMessageBox.StandardButton)
562
8bf0dbc1ca6a Added a wizard for the eric5 message box (E5MessageBox).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
191 @return button pressed by the user (QMessageBox.StandardButton)
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
192 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
193 return __messageBox(parent, title, text, QMessageBox.Question,
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
194 buttons, defaultButton)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
195
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
196
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
197 def warning(parent, title, text,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
198 buttons=QMessageBox.Ok, defaultButton=QMessageBox.NoButton):
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
199 """
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
200 Function to show a modal warning message box.
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
201
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
202 @param parent parent widget of the message box (QWidget)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
203 @param title caption of the message box (string)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
204 @param text text to be shown by the message box (string)
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
205 @param buttons flags indicating which buttons to show
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
206 (QMessageBox.StandardButtons)
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
207 @param defaultButton flag indicating the default button
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
208 (QMessageBox.StandardButton)
562
8bf0dbc1ca6a Added a wizard for the eric5 message box (E5MessageBox).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
209 @return button pressed by the user (QMessageBox.StandardButton)
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
210 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
211 return __messageBox(parent, title, text, QMessageBox.Warning,
537
72b32daeb8d6 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 536
diff changeset
212 buttons, defaultButton)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
213
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
214 ################################################################################
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
215 ## Additional convenience functions ##
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
216 ################################################################################
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
217
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
218
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
219 def yesNo(parent, title, text, icon=Question, yesDefault=False):
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
220 """
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
221 Function to show a model yes/no message box.
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
222
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
223 @param parent parent widget of the message box (QWidget)
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
224 @param title caption of the message box (string)
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
225 @param text text to be shown by the message box (string)
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
226 @keyparam icon icon for the dialog (Critical, Information, Question or Warning)
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
227 @keyparam yesDefault flag indicating that the Yes button should be the default
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
228 button (boolean)
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
229 @return flag indicating the selection of the Yes button (boolean)
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
230 """
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
231 assert icon in [Critical, Information, Question, Warning]
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
232
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
233 res = __messageBox(parent, title, text, icon,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
234 QMessageBox.StandardButtons(QMessageBox.Yes | QMessageBox.No),
541
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
235 yesDefault and QMessageBox.Yes or QMessageBox.No)
00e1a5d060c5 Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 537
diff changeset
236 return res == QMessageBox.Yes
549
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
237
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
238
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
239 def retryAbort(parent, title, text, icon=Question):
550
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
240 """
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
241 Function to show a model abort/retry message box.
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
242
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
243 @param parent parent widget of the message box (QWidget)
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
244 @param title caption of the message box (string)
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
245 @param text text to be shown by the message box (string)
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
246 @keyparam icon icon for the dialog (Critical, Information, Question or Warning)
550
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
247 @return flag indicating the selection of the Retry button (boolean)
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
248 """
553
5af61623ae3c Continued replacing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 550
diff changeset
249 assert icon in [Critical, Information, Question, Warning]
550
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
250
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
251 res = __messageBox(parent, title, text, icon,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
252 QMessageBox.StandardButtons(QMessageBox.Retry | QMessageBox.Abort),
550
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
253 QMessageBox.Retry)
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
254 return res == QMessageBox.Retry
22b951013193 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 549
diff changeset
255
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
256
549
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
257 def okToClearData(parent, title, text, saveFunc):
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
258 """
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
259 Function to show a model message box to ask for clearing the data.
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
260
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
261 @param parent parent widget of the message box (QWidget)
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
262 @param title caption of the message box (string)
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
263 @param text text to be shown by the message box (string)
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
264 @param saveFunc reference to a function performing the save action. It
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
265 must be a parameterless function returning a flag indicating success.
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
266 @return flag indicating that it is ok to clear the data (boolean)
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
267 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
268 res = __messageBox(parent, title, text, QMessageBox.Warning,
549
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
269 QMessageBox.StandardButtons(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
270 QMessageBox.Abort | QMessageBox.Discard | QMessageBox.Save),
549
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
271 QMessageBox.Save)
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
272 if res == QMessageBox.Abort:
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
273 return False
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
274 if res == QMessageBox.Save:
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
275 return saveFunc()
fe99d46d56c8 Continued replacing QMessageBox.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 545
diff changeset
276 return True

eric ide

mercurial