ExtensionCorba/IdlCompilerDefineNameDialog.py

changeset 1
d4384e4d7aff
child 32
cab6795a8df6
equal deleted inserted replaced
0:02171512ef2f 1:d4384e4d7aff
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2018 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing a dialog to enter the name-value pair to define a variable
8 for the IDL compiler.
9 """
10
11 from PyQt6.QtCore import pyqtSlot
12 from PyQt6.QtWidgets import QDialog, QDialogButtonBox
13
14 from .Ui_IdlCompilerDefineNameDialog import Ui_IdlCompilerDefineNameDialog
15
16
17 class IdlCompilerDefineNameDialog(QDialog, Ui_IdlCompilerDefineNameDialog):
18 """
19 Class implementing a dialog to enter the name-value pair to define a
20 variable for the IDL compiler.
21 """
22
23 def __init__(self, name="", value="", parent=None):
24 """
25 Constructor
26
27 @param name name of the variable
28 @type str
29 @param value value of the variable
30 @type str
31 @param parent reference to the parent widget
32 @type QWidget
33 """
34 super().__init__(parent)
35 self.setupUi(self)
36
37 self.nameEdit.setText(name)
38 self.valueEdit.setText(value)
39
40 msh = self.minimumSizeHint()
41 self.resize(max(self.width(), msh.width()), msh.height())
42
43 self.__updateOkButton()
44
45 def __updateOkButton(self):
46 """
47 Private slot to update the enable state of the OK button.
48 """
49 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
50 bool(self.nameEdit.text())
51 )
52
53 @pyqtSlot(str)
54 def on_nameEdit_textChanged(self, txt):
55 """
56 Private slot to handle changes of the name.
57
58 @param txt current text of the name edit
59 @type str
60 """
61 self.__updateOkButton()
62
63 def getData(self):
64 """
65 Public method to get the entered data.
66
67 @return tuple containing the variable name and value
68 @rtype tuple of (str, str)
69 """
70 return (
71 self.nameEdit.text().strip(),
72 self.valueEdit.text().strip(),
73 )

eric ide

mercurial