Mon, 07 Nov 2022 17:19:58 +0100
Corrected/acknowledged some bad import style and removed some obsolete code.
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
8881
54e42bc2437a
Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
3 | # Copyright (c) 2018 - 2022 Detlev Offenbach <detlev@die-offenbachs.de> |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
4 | # |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
5 | |
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
7 | Module implementing a dialog to enter the name-value pair to define a variable |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
8 | for the IDL compiler. |
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | """ |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
10 | |
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
|
11 | from PyQt6.QtCore import pyqtSlot |
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
|
12 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox |
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
13 | |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
14 | from .Ui_IdlCompilerDefineNameDialog import Ui_IdlCompilerDefineNameDialog |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
16 | |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
17 | class IdlCompilerDefineNameDialog(QDialog, Ui_IdlCompilerDefineNameDialog): |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
18 | """ |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
19 | Class implementing a dialog to enter the name-value pair to define a |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
20 | variable for the IDL compiler. |
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
21 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
22 | |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
23 | def __init__(self, name="", value="", parent=None): |
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
24 | """ |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
25 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
26 | |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
27 | @param name name of the variable |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
28 | @type str |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
29 | @param value value of the variable |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
30 | @type str |
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
31 | @param parent reference to the parent widget |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
32 | @type QWidget |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | """ |
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
|
34 | super().__init__(parent) |
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
35 | self.setupUi(self) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
36 | |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
37 | self.nameEdit.setText(name) |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
38 | self.valueEdit.setText(value) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
39 | |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
40 | msh = self.minimumSizeHint() |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
41 | self.resize(max(self.width(), msh.width()), msh.height()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
42 | |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
43 | self.__updateOkButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
44 | |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
45 | def __updateOkButton(self): |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
46 | """ |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
47 | Private slot to update the enable state of the OK button. |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
48 | """ |
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
|
49 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
50 | bool(self.nameEdit.text()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
51 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | |
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
53 | @pyqtSlot(str) |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
54 | def on_nameEdit_textChanged(self, txt): |
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
55 | """ |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
56 | Private slot to handle changes of the name. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
57 | |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
58 | @param txt current text of the name edit |
6442
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | @type str |
9d42b6c08a27
IDLCompilerOptionsDialog: started to implement a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | """ |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
61 | self.__updateOkButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
62 | |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
63 | def getData(self): |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
64 | """ |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
65 | Public method to get the entered data. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
66 | |
6445
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
67 | @return tuple containing the variable name and value |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
68 | @rtype tuple of (str, str) |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
69 | """ |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
70 | return ( |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
71 | self.nameEdit.text().strip(), |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
72 | self.valueEdit.text().strip(), |
2b022e5ba54c
IDLCompilerOptionsDialog: finished implementing a dialog to enter options for the IDL compiler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6442
diff
changeset
|
73 | ) |