eric6/Project/IdlCompilerDefineNameDialog.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2018 - 2019 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 __future__ import unicode_literals
12
13 from PyQt5.QtCore import pyqtSlot
14 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
15
16 from .Ui_IdlCompilerDefineNameDialog import Ui_IdlCompilerDefineNameDialog
17
18
19 class IdlCompilerDefineNameDialog(QDialog, Ui_IdlCompilerDefineNameDialog):
20 """
21 Class implementing a dialog to enter the name-value pair to define a
22 variable for the IDL compiler.
23 """
24 def __init__(self, name="", value="", parent=None):
25 """
26 Constructor
27
28 @param name name of the variable
29 @type str
30 @param value value of the variable
31 @type str
32 @param parent reference to the parent widget
33 @type QWidget
34 """
35 super(IdlCompilerDefineNameDialog, self).__init__(parent)
36 self.setupUi(self)
37
38 self.nameEdit.setText(name)
39 self.valueEdit.setText(value)
40
41 msh = self.minimumSizeHint()
42 self.resize(max(self.width(), msh.width()), msh.height())
43
44 self.__updateOkButton()
45
46 def __updateOkButton(self):
47 """
48 Private slot to update the enable state of the OK button.
49 """
50 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(
51 bool(self.nameEdit.text()))
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