iPhone-Backup-Analyzer-2 icon indicating copy to clipboard operation
iPhone-Backup-Analyzer-2 copied to clipboard

Error messages do not fit on small boxes

Open aapo opened this issue 11 years ago • 0 comments

QtGui.QMessageBox might not be the best gui-element for error messages. Most annoying is the fact that it cannot be resized (e.g. in case when details contains Backtrace). It could be improved something like:

diff --git a/main.py b/main.py
index 73ed244..a916f7b 100644
--- a/main.py
+++ b/main.py
@@ -68,6 +68,31 @@ class AboutWindow(QtGui.QWidget):
                self.ui.about_version.setText("Ver. %s (%s)"%(iPBAVersion, iPBAVersionDate))

 # ------------------------------------------------------------------------------------------------             
+class MyMessageBox(QtGui.QMessageBox):
+    def __init__(self):
+        QtGui.QMessageBox.__init__(self)
+        self.setSizeGripEnabled(True)
+
+    def event(self, e):
+        result = QtGui.QMessageBox.event(self, e)
+
+        self.setMinimumHeight(0)
+        self.setMaximumHeight(16777215)
+        self.setMinimumWidth(0)
+        self.setMaximumWidth(16777215)
+        self.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
+
+        textEdit = self.findChild(QtGui.QTextEdit)
+        if textEdit != None :
+            textEdit.setMinimumHeight(0)
+            textEdit.setMaximumHeight(16777215)
+            textEdit.setMinimumWidth(0)
+            textEdit.setMaximumWidth(16777215)
+            textEdit.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
+
+        return result
+# ------------------------------------------------------------------------------------------------             
+

 class PlistWidget(QtGui.QWidget):

@@ -839,7 +864,7 @@ class IPBA2(QtGui.QMainWindow):


        def error(self, text):
-               msgBox = QtGui.QMessageBox()
+               msgBox = MyMessageBox()
                msgBox.setText(text)

                detailedText = "Type: %s"%sys.exc_info()[0].__name__

And/or:

+print text
+print detailedText

aapo avatar Feb 20 '14 11:02 aapo