diff -r 6d8d39753c82 -r 72b32daeb8d6 E5Gui/E5MessageBox.py --- a/E5Gui/E5MessageBox.py Mon Aug 30 20:16:34 2010 +0200 +++ b/E5Gui/E5MessageBox.py Tue Aug 31 12:17:02 2010 +0200 @@ -10,14 +10,15 @@ from PyQt4.QtCore import Qt from PyQt4.QtGui import QMessageBox, QApplication -def information(parent, title, text, - buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton): +def __messageBox(parent, title, text, icon, + buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton): """ - Function to show a modal information message box. + Private module function to show a modal message box. - @param parent parent widget of the message box - @param title caption of the message box - @param text text to be shown by the message box + @param parent parent widget of the message box (QWidget) + @param title caption of the message box (string) + @param text text to be shown by the message box (string) + @param icon type of icon to be shown (QMessageBox.Icon) @param buttons flags indicating which buttons to show (QMessageBox.StandardButtons) @param defaultButton flag indicating the default button @@ -26,7 +27,7 @@ (QMessageBox.StandardButton) """ messageBox = QMessageBox(parent) - messageBox.setIcon(QMessageBox.Information) + messageBox.setIcon(icon) if parent is not None: messageBox.setWindowModality(Qt.WindowModal) messageBox.setWindowTitle("{0} - {1}".format( @@ -40,3 +41,75 @@ return QMessageBox.NoButton else: return messageBox.standardButton(clickedButton) + +def critical(parent, title, text, + buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton): + """ + Function to show a modal critical message box. + + @param parent parent widget of the message box (QWidget) + @param title caption of the message box (string) + @param text text to be shown by the message box (string) + @param buttons flags indicating which buttons to show + (QMessageBox.StandardButtons) + @param defaultButton flag indicating the default button + (QMessageBox.StandardButton) + @return button pressed by the user + (QMessageBox.StandardButton) + """ + return __messageBox(parent, title, text, QMessageBox.Critical, + buttons, defaultButton) + +def information(parent, title, text, + buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton): + """ + Function to show a modal information message box. + + @param parent parent widget of the message box (QWidget) + @param title caption of the message box (string) + @param text text to be shown by the message box (string) + @param buttons flags indicating which buttons to show + (QMessageBox.StandardButtons) + @param defaultButton flag indicating the default button + (QMessageBox.StandardButton) + @return button pressed by the user + (QMessageBox.StandardButton) + """ + return __messageBox(parent, title, text, QMessageBox.Information, + buttons, defaultButton) + +def question(parent, title, text, + buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton): + """ + Function to show a modal question message box. + + @param parent parent widget of the message box (QWidget) + @param title caption of the message box (string) + @param text text to be shown by the message box (string) + @param buttons flags indicating which buttons to show + (QMessageBox.StandardButtons) + @param defaultButton flag indicating the default button + (QMessageBox.StandardButton) + @return button pressed by the user + (QMessageBox.StandardButton) + """ + return __messageBox(parent, title, text, QMessageBox.Question, + buttons, defaultButton) + +def warning(parent, title, text, + buttons = QMessageBox.Ok, defaultButton = QMessageBox.NoButton): + """ + Function to show a modal warning message box. + + @param parent parent widget of the message box (QWidget) + @param title caption of the message box (string) + @param text text to be shown by the message box (string) + @param buttons flags indicating which buttons to show + (QMessageBox.StandardButtons) + @param defaultButton flag indicating the default button + (QMessageBox.StandardButton) + @return button pressed by the user + (QMessageBox.StandardButton) + """ + return __messageBox(parent, title, text, QMessageBox.Warning, + buttons, defaultButton)