eric7/E5Gui/E5PlainTextDialog.py

branch
eric7
changeset 8312
800c432b34c8
parent 8218
7c09585bd960
child 8318
962bce857696
equal deleted inserted replaced
8311:4e8b98454baa 8312:800c432b34c8
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2020 - 2021 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().__init__(parent)
33 self.setupUi(self)
34
35 self.copyButton = self.buttonBox.addButton(
36 self.tr("Copy to Clipboard"),
37 QDialogButtonBox.ButtonRole.ActionRole)
38 self.copyButton.clicked.connect(self.on_copyButton_clicked)
39
40 self.setWindowTitle(title)
41 self.textEdit.setPlainText(text)
42
43 @pyqtSlot()
44 def on_copyButton_clicked(self):
45 """
46 Private slot to copy the text to the clipboard.
47 """
48 txt = self.textEdit.toPlainText()
49 cb = QGuiApplication.clipboard()
50 cb.setText(txt)

eric ide

mercurial