E5Gui/E5MessageBox.py

changeset 537
72b32daeb8d6
parent 536
6d8d39753c82
child 541
00e1a5d060c5
equal deleted inserted replaced
536:6d8d39753c82 537:72b32daeb8d6
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 def information(parent, title, text, 13 def __messageBox(parent, title, text, icon,
14 buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton): 14 buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton):
15 """ 15 """
16 Function to show a modal information message box. 16 Private module function to show a modal message box.
17 17
18 @param parent parent widget of the message box 18 @param parent parent widget of the message box (QWidget)
19 @param title caption of the message box 19 @param title caption of the message box (string)
20 @param text text to be shown by the message box 20 @param text text to be shown by the message box (string)
21 @param icon type of icon to be shown (QMessageBox.Icon)
21 @param buttons flags indicating which buttons to show 22 @param buttons flags indicating which buttons to show
22 (QMessageBox.StandardButtons) 23 (QMessageBox.StandardButtons)
23 @param defaultButton flag indicating the default button 24 @param defaultButton flag indicating the default button
24 (QMessageBox.StandardButton) 25 (QMessageBox.StandardButton)
25 @return button pressed by the user 26 @return button pressed by the user
26 (QMessageBox.StandardButton) 27 (QMessageBox.StandardButton)
27 """ 28 """
28 messageBox = QMessageBox(parent) 29 messageBox = QMessageBox(parent)
29 messageBox.setIcon(QMessageBox.Information) 30 messageBox.setIcon(icon)
30 if parent is not None: 31 if parent is not None:
31 messageBox.setWindowModality(Qt.WindowModal) 32 messageBox.setWindowModality(Qt.WindowModal)
32 messageBox.setWindowTitle("{0} - {1}".format( 33 messageBox.setWindowTitle("{0} - {1}".format(
33 QApplication.applicationName(), title)) 34 QApplication.applicationName(), title))
34 messageBox.setText(text) 35 messageBox.setText(text)
38 clickedButton = messageBox.clickedButton() 39 clickedButton = messageBox.clickedButton()
39 if clickedButton is None: 40 if clickedButton is None:
40 return QMessageBox.NoButton 41 return QMessageBox.NoButton
41 else: 42 else:
42 return messageBox.standardButton(clickedButton) 43 return messageBox.standardButton(clickedButton)
44
45 def critical(parent, title, text,
46 buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton):
47 """
48 Function to show a modal critical message box.
49
50 @param parent parent widget of the message box (QWidget)
51 @param title caption of the message box (string)
52 @param text text to be shown by the message box (string)
53 @param buttons flags indicating which buttons to show
54 (QMessageBox.StandardButtons)
55 @param defaultButton flag indicating the default button
56 (QMessageBox.StandardButton)
57 @return button pressed by the user
58 (QMessageBox.StandardButton)
59 """
60 return __messageBox(parent, title, text, QMessageBox.Critical,
61 buttons, defaultButton)
62
63 def information(parent, title, text,
64 buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton):
65 """
66 Function to show a modal information message box.
67
68 @param parent parent widget of the message box (QWidget)
69 @param title caption of the message box (string)
70 @param text text to be shown by the message box (string)
71 @param buttons flags indicating which buttons to show
72 (QMessageBox.StandardButtons)
73 @param defaultButton flag indicating the default button
74 (QMessageBox.StandardButton)
75 @return button pressed by the user
76 (QMessageBox.StandardButton)
77 """
78 return __messageBox(parent, title, text, QMessageBox.Information,
79 buttons, defaultButton)
80
81 def question(parent, title, text,
82 buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton):
83 """
84 Function to show a modal question message box.
85
86 @param parent parent widget of the message box (QWidget)
87 @param title caption of the message box (string)
88 @param text text to be shown by the message box (string)
89 @param buttons flags indicating which buttons to show
90 (QMessageBox.StandardButtons)
91 @param defaultButton flag indicating the default button
92 (QMessageBox.StandardButton)
93 @return button pressed by the user
94 (QMessageBox.StandardButton)
95 """
96 return __messageBox(parent, title, text, QMessageBox.Question,
97 buttons, defaultButton)
98
99 def warning(parent, title, text,
100 buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton):
101 """
102 Function to show a modal warning message box.
103
104 @param parent parent widget of the message box (QWidget)
105 @param title caption of the message box (string)
106 @param text text to be shown by the message box (string)
107 @param buttons flags indicating which buttons to show
108 (QMessageBox.StandardButtons)
109 @param defaultButton flag indicating the default button
110 (QMessageBox.StandardButton)
111 @return button pressed by the user
112 (QMessageBox.StandardButton)
113 """
114 return __messageBox(parent, title, text, QMessageBox.Warning,
115 buttons, defaultButton)

eric ide

mercurial