src/eric7/EricWidgets/EricMessageBox.py

branch
eric7
changeset 11034
7b8a21fd2d58
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
--- a/src/eric7/EricWidgets/EricMessageBox.py	Sun Nov 03 12:34:02 2024 +0100
+++ b/src/eric7/EricWidgets/EricMessageBox.py	Sun Nov 03 17:50:34 2024 +0100
@@ -7,7 +7,7 @@
 Module implementing QMessageBox replacements and more convenience function.
 """
 
-from PyQt6.QtCore import Qt
+from PyQt6.QtCore import QCoreApplication, Qt
 from PyQt6.QtWidgets import QApplication, QMessageBox
 
 ###############################################################################
@@ -142,6 +142,9 @@
     @return button pressed by the user
     @rtype QMessageBox.StandardButton
     """
+    if parent is None:
+        parent = QCoreApplication.instance().getMainWindow()
+
     messageBox = QMessageBox(parent)
     messageBox.setIcon(icon)
     if parent is not None:
@@ -164,9 +167,36 @@
         return messageBox.standardButton(clickedButton)
 
 
-# the about functions are here for consistency
-about = QMessageBox.about
-aboutQt = QMessageBox.aboutQt
+def about(parent, title, text):
+    """
+    Function to show a modal dialog with some text about the application.
+
+    @param parent parent widget of the message box
+    @type QWidget
+    @param title caption of the message box
+    @type str
+    @param text text to be shown by the message box
+    @type str
+    """
+    if parent is None:
+        parent = QCoreApplication.instance().getMainWindow()
+
+    QMessageBox.about(parent, title, text)
+
+
+def aboutQt(parent, title=""):
+    """
+    Function to show a modal dialog with text about Qt.
+
+    @param parent parent widget of the message box
+    @type QWidget
+    @param title caption of the message box (defaults to "")
+    @type str (optional)
+    """
+    if parent is None:
+        parent = QCoreApplication.instance().getMainWindow()
+
+    QMessageBox.aboutQt(parent, title)
 
 
 def critical(

eric ide

mercurial