E5Gui/E5MessageBox.py

changeset 536
6d8d39753c82
child 537
72b32daeb8d6
equal deleted inserted replaced
535:4b00d7336e19 536:6d8d39753c82
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2010 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing QMessageBox replacements and more convenience function.
8 """
9
10 from PyQt4.QtCore import Qt
11 from PyQt4.QtGui import QMessageBox, QApplication
12
13 def information(parent, title, text,
14 buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton):
15 """
16 Function to show a modal information message box.
17
18 @param parent parent widget of the message box
19 @param title caption of the message box
20 @param text text to be shown by the message box
21 @param buttons flags indicating which buttons to show
22 (QMessageBox.StandardButtons)
23 @param defaultButton flag indicating the default button
24 (QMessageBox.StandardButton)
25 @return button pressed by the user
26 (QMessageBox.StandardButton)
27 """
28 messageBox = QMessageBox(parent)
29 messageBox.setIcon(QMessageBox.Information)
30 if parent is not None:
31 messageBox.setWindowModality(Qt.WindowModal)
32 messageBox.setWindowTitle("{0} - {1}".format(
33 QApplication.applicationName(), title))
34 messageBox.setText(text)
35 messageBox.setStandardButtons(buttons)
36 messageBox.setDefaultButton(defaultButton)
37 messageBox.exec_()
38 clickedButton = messageBox.clickedButton()
39 if clickedButton is None:
40 return QMessageBox.NoButton
41 else:
42 return messageBox.standardButton(clickedButton)

eric ide

mercurial