eric6/E5Gui/E5PlainTextDialog.py

changeset 7810
f8afd2238723
child 7923
91e843545d9a
equal deleted inserted replaced
7809:f5a61d073100 7810:f8afd2238723
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2020 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to show some plain text.
8 """
9
10 from PyQt5.QtCore import pyqtSlot
11 from PyQt5.QtGui import QGuiApplication
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
13
14 from .Ui_E5PlainTextDialog import Ui_E5PlainTextDialog
15
16
17 class E5PlainTextDialog(QDialog, Ui_E5PlainTextDialog):
18 """
19 Class implementing a dialog to show some plain text.
20 """
21 def __init__(self, title="", text="", parent=None):
22 """
23 Constructor
24
25 @param title title of the window
26 @type str
27 @param text text to be shown
28 @type str
29 @param parent reference to the parent widget
30 @type QWidget
31 """
32 super(E5PlainTextDialog, self).__init__(parent)
33 self.setupUi(self)
34
35 self.copyButton = self.buttonBox.addButton(
36 self.tr("Copy to Clipboard"), QDialogButtonBox.ActionRole)
37 self.copyButton.clicked.connect(self.on_copyButton_clicked)
38
39 self.setWindowTitle(title)
40 self.textEdit.setPlainText(text)
41
42 @pyqtSlot()
43 def on_copyButton_clicked(self):
44 """
45 Private slot to copy the text to the clipboard.
46 """
47 txt = self.textEdit.toPlainText()
48 cb = QGuiApplication.clipboard()
49 cb.setText(txt)

eric ide

mercurial