src/eric7/EricWidgets/EricPlainTextDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
16 16
17 class EricPlainTextDialog(QDialog, Ui_EricPlainTextDialog): 17 class EricPlainTextDialog(QDialog, Ui_EricPlainTextDialog):
18 """ 18 """
19 Class implementing a dialog to show some plain text. 19 Class implementing a dialog to show some plain text.
20 """ 20 """
21
21 def __init__(self, title="", text="", readOnly=True, parent=None): 22 def __init__(self, title="", text="", readOnly=True, parent=None):
22 """ 23 """
23 Constructor 24 Constructor
24 25
25 @param title title of the dialog (defaults to "") 26 @param title title of the dialog (defaults to "")
26 @type str (optional) 27 @type str (optional)
27 @param text text to be shown (defaults to "") 28 @param text text to be shown (defaults to "")
28 @type str (optional) 29 @type str (optional)
29 @param readOnly flag indicating a read-only dialog (defaults to True) 30 @param readOnly flag indicating a read-only dialog (defaults to True)
31 @param parent reference to the parent widget (defaults to None) 32 @param parent reference to the parent widget (defaults to None)
32 @type QWidget (optional) 33 @type QWidget (optional)
33 """ 34 """
34 super().__init__(parent) 35 super().__init__(parent)
35 self.setupUi(self) 36 self.setupUi(self)
36 37
37 self.copyButton = self.buttonBox.addButton( 38 self.copyButton = self.buttonBox.addButton(
38 self.tr("Copy to Clipboard"), 39 self.tr("Copy to Clipboard"), QDialogButtonBox.ButtonRole.ActionRole
39 QDialogButtonBox.ButtonRole.ActionRole) 40 )
40 self.copyButton.clicked.connect(self.on_copyButton_clicked) 41 self.copyButton.clicked.connect(self.on_copyButton_clicked)
41 42
42 self.setWindowTitle(title) 43 self.setWindowTitle(title)
43 self.textEdit.setPlainText(text) 44 self.textEdit.setPlainText(text)
44 self.textEdit.setReadOnly(readOnly) 45 self.textEdit.setReadOnly(readOnly)
45 46
46 @pyqtSlot() 47 @pyqtSlot()
47 def on_copyButton_clicked(self): 48 def on_copyButton_clicked(self):
48 """ 49 """
49 Private slot to copy the text to the clipboard. 50 Private slot to copy the text to the clipboard.
50 """ 51 """
51 txt = self.textEdit.toPlainText() 52 txt = self.textEdit.toPlainText()
52 cb = QGuiApplication.clipboard() 53 cb = QGuiApplication.clipboard()
53 cb.setText(txt) 54 cb.setText(txt)
54 55
55 def toPlainText(self): 56 def toPlainText(self):
56 """ 57 """
57 Public method to get the plain text. 58 Public method to get the plain text.
58 59
59 @return contents of the plain text edit 60 @return contents of the plain text edit
60 @rtype str 61 @rtype str
61 """ 62 """
62 return self.textEdit.toPlainText() 63 return self.textEdit.toPlainText()

eric ide

mercurial