Sat, 22 May 2021 19:58:24 +0200
Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
7923
91e843545d9a
Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7780
diff
changeset
|
3 | # Copyright (c) 2018 - 2021 Detlev Offenbach <detlev@die-offenbachs.de> |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing a dialog to enter some text. |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
10 | from PyQt6.QtWidgets import ( |
7252
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
11 | QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QLineEdit |
c5e3705073eb
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7229
diff
changeset
|
12 | ) |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8350
diff
changeset
|
15 | class EricTextInputDialog(QDialog): |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | Class implementing a dialog to enter some text. |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
19 | def __init__(self, parent=None): |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
20 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | Constructor |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
22 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
23 | @param parent reference to the parent widget |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | @type QWidget |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
26 | super().__init__(parent) |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
27 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
28 | self.setMaximumWidth(600) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
29 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
30 | self.__layout = QVBoxLayout(self) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | self.__label = QLabel(self) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | self.__layout.addWidget(self.__label) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
34 | |
8350
74a3b2a6a944
Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
35 | self.__lineEdit = QLineEdit(self) |
74a3b2a6a944
Removed all references to E5ComboBox and most references to E5LineEdit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
36 | self.__lineEdit.setClearButtonEnabled(True) |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
37 | self.__layout.addWidget(self.__lineEdit) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
38 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
39 | self.__buttonBox = QDialogButtonBox( |
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
|
40 | QDialogButtonBox.StandardButton.Ok | |
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
|
41 | QDialogButtonBox.StandardButton.Cancel, self) |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
42 | self.__layout.addWidget(self.__buttonBox) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
43 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
44 | self.__buttonBox.accepted.connect(self.accept) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
45 | self.__buttonBox.rejected.connect(self.reject) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
46 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
47 | msh = self.minimumSizeHint() |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
48 | self.resize(max(self.width(), msh.width()), msh.height()) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
49 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
50 | def setTextEchoMode(self, echoMode): |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
51 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
52 | Public method to set the echo mode of the line edit. |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
54 | @param echoMode echo mode of the line edit |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | @type QLineEdit.EchoMode |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
56 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
57 | self.__lineEdit.setEchoMode(echoMode) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
58 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | def textEchoMode(self): |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | Public method to get the current echo mode of the line edit. |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | @return echo mode of the line edit |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
64 | @rtype QLineEdit.EchoMode |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
65 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | return self.__lineEdit.echoMode() |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
68 | def setTextValue(self, text): |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
69 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
70 | Public method to set the text of the line edit. |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
71 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
72 | @param text text for the line edit |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | @type str |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
74 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
75 | self.__lineEdit.setText(text) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
77 | def textValue(self): |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
78 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
79 | Public method to get the text of the line edit. |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
80 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
81 | @return text of the line edit |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
82 | @rtype str |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
83 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
84 | return self.__lineEdit.text() |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
85 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
86 | def setLabelText(self, text): |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
87 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
88 | Public method to set the label text. |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
89 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
90 | @param text label text |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
91 | @type str |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
92 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
93 | self.__label.setText(text) |
6533
b7df503cb673
E5TextInputDialog: did some finetuning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6532
diff
changeset
|
94 | |
b7df503cb673
E5TextInputDialog: did some finetuning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6532
diff
changeset
|
95 | msh = self.minimumSizeHint() |
b7df503cb673
E5TextInputDialog: did some finetuning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6532
diff
changeset
|
96 | labelSizeHint = self.__label.sizeHint() |
b7df503cb673
E5TextInputDialog: did some finetuning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6532
diff
changeset
|
97 | self.resize(max(self.width(), msh.width(), labelSizeHint.width()), |
b7df503cb673
E5TextInputDialog: did some finetuning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6532
diff
changeset
|
98 | msh.height()) |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
99 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
100 | def labelText(self): |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
101 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
102 | Public method to get the current label text. |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
103 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | @return current label text |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
105 | @rtype str |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
106 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
107 | return self.label.text() |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
108 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
109 | |
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
|
110 | def getText(parent, title, label, mode=QLineEdit.EchoMode.Normal, text="", |
6533
b7df503cb673
E5TextInputDialog: did some finetuning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6532
diff
changeset
|
111 | minimumWidth=300): |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | """ |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | Function to get create a dialog to enter some text and return it. |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
115 | @param parent reference to the parent widget |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
116 | @type QWidget |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
117 | @param title title of the dialog |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
118 | @type str |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
119 | @param label label of the dialog |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
120 | @type str |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
121 | @param mode echo mode of the line edit |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | @type QLineEdit.EchoMode |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | @param text initial text of the line edit |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
124 | @type str |
6533
b7df503cb673
E5TextInputDialog: did some finetuning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6532
diff
changeset
|
125 | @param minimumWidth minimum width of the dialog |
b7df503cb673
E5TextInputDialog: did some finetuning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6532
diff
changeset
|
126 | @type int |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | @return tuple containing a flag indicating the dialog was accepted and the |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | entered text |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
129 | @rtype tuple of (bool, str) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
130 | """ |
8356
68ec9c3d4de5
Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8350
diff
changeset
|
131 | dlg = EricTextInputDialog(parent) |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
132 | dlg.setWindowTitle(title) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
133 | dlg.setLabelText(label) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
134 | dlg.setTextEchoMode(mode) |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
135 | dlg.setTextValue(text) |
6533
b7df503cb673
E5TextInputDialog: did some finetuning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6532
diff
changeset
|
136 | dlg.setMinimumWidth(minimumWidth) |
b7df503cb673
E5TextInputDialog: did some finetuning.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6532
diff
changeset
|
137 | |
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
|
138 | if dlg.exec() == QDialog.DialogCode.Accepted: |
6532
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
139 | return True, dlg.textValue() |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
140 | else: |
f253f0f9ea7f
E5TextInputDialog: added a text input dialog using the clearable line edit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
141 | return False, "" |