eric6/E5Gui/E5PlainTextDialog.py

Tue, 02 Mar 2021 17:17:09 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 02 Mar 2021 17:17:09 +0100
changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8218
7c09585bd960
permissions
-rw-r--r--

Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.

7810
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7810
diff changeset
3 # Copyright (c) 2020 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
7810
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to show some plain text.
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import pyqtSlot
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11 from PyQt5.QtGui import QGuiApplication
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 from .Ui_E5PlainTextDialog import Ui_E5PlainTextDialog
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 class E5PlainTextDialog(QDialog, Ui_E5PlainTextDialog):
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Class implementing a dialog to show some plain text.
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 """
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 def __init__(self, title="", text="", parent=None):
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 """
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 Constructor
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 @param title title of the window
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @type str
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 @param text text to be shown
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 @type str
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 @param parent reference to the parent widget
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 @type QWidget
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 """
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 super(E5PlainTextDialog, self).__init__(parent)
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.setupUi(self)
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 self.copyButton = self.buttonBox.addButton(
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
36 self.tr("Copy to Clipboard"),
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
37 QDialogButtonBox.ButtonRole.ActionRole)
7810
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.copyButton.clicked.connect(self.on_copyButton_clicked)
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 self.setWindowTitle(title)
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.textEdit.setPlainText(text)
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 @pyqtSlot()
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 def on_copyButton_clicked(self):
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 """
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 Private slot to copy the text to the clipboard.
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 """
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 txt = self.textEdit.toPlainText()
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 cb = QGuiApplication.clipboard()
f8afd2238723 Install Info: extended the dialog by a delete action and an action to show upgrade instructions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 cb.setText(txt)

eric ide

mercurial