eric7/EricWidgets/EricPlainTextDialog.py

branch
unittest
changeset 9093
437bfe0c5793
parent 8881
54e42bc2437a
--- a/eric7/EricWidgets/EricPlainTextDialog.py	Mon May 23 16:50:39 2022 +0200
+++ b/eric7/EricWidgets/EricPlainTextDialog.py	Mon May 23 17:18:58 2022 +0200
@@ -18,16 +18,18 @@
     """
     Class implementing a dialog to show some plain text.
     """
-    def __init__(self, title="", text="", parent=None):
+    def __init__(self, title="", text="", readOnly=True, parent=None):
         """
         Constructor
         
-        @param title title of the window
-        @type str
-        @param text text to be shown
-        @type str
-        @param parent reference to the parent widget
-        @type QWidget
+        @param title title of the dialog (defaults to "")
+        @type str (optional)
+        @param text text to be shown (defaults to "")
+        @type str (optional)
+        @param readOnly flag indicating a read-only dialog (defaults to True)
+        @type bool (optional)
+        @param parent reference to the parent widget (defaults to None)
+        @type QWidget (optional)
         """
         super().__init__(parent)
         self.setupUi(self)
@@ -39,6 +41,7 @@
         
         self.setWindowTitle(title)
         self.textEdit.setPlainText(text)
+        self.textEdit.setReadOnly(readOnly)
     
     @pyqtSlot()
     def on_copyButton_clicked(self):
@@ -48,3 +51,12 @@
         txt = self.textEdit.toPlainText()
         cb = QGuiApplication.clipboard()
         cb.setText(txt)
+    
+    def toPlainText(self):
+        """
+        Public method to get the plain text.
+        
+        @return contents of the plain text edit
+        @rtype str
+        """
+        return self.textEdit.toPlainText()

eric ide

mercurial