eric7/E5Gui/E5PlainTextDialog.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8355
8a7677a63c8d
child 8357
a081458cc57b
equal deleted inserted replaced
8355:8a7677a63c8d 8356:68ec9c3d4de5
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 PyQt6.QtCore import pyqtSlot
11 from PyQt6.QtGui import QGuiApplication
12 from PyQt6.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