--- a/Project/IdlCompilerDefineNameDialog.py Sun Jul 29 12:53:57 2018 +0200 +++ b/Project/IdlCompilerDefineNameDialog.py Sun Jul 29 14:00:23 2018 +0200 @@ -1,36 +1,71 @@ # -*- coding: utf-8 -*- +# Copyright (c) 2018 Detlev Offenbach <detlev@die-offenbachs.de> +# + """ -Module implementing IdlCompilerDefineNameDialog. +Module implementing a dialog to enter the name-value pair to define a variable +for the IDL compiler. """ from PyQt5.QtCore import pyqtSlot -from PyQt5.QtWidgets import QDialog +from PyQt5.QtWidgets import QDialog, QDialogButtonBox from .Ui_IdlCompilerDefineNameDialog import Ui_IdlCompilerDefineNameDialog class IdlCompilerDefineNameDialog(QDialog, Ui_IdlCompilerDefineNameDialog): """ - Class documentation goes here. + Class implementing a dialog to enter the name-value pair to define a + variable for the IDL compiler. """ - def __init__(self, parent=None): + def __init__(self, name="", value="", parent=None): """ Constructor + @param name name of the variable + @type str + @param value value of the variable + @type str @param parent reference to the parent widget @type QWidget """ super(IdlCompilerDefineNameDialog, self).__init__(parent) self.setupUi(self) + + self.nameEdit.setText(name) + self.valueEdit.setText(value) + + msh = self.minimumSizeHint() + self.resize(max(self.width(), msh.width()), msh.height()) + + self.__updateOkButton() + + def __updateOkButton(self): + """ + Private slot to update the enable state of the OK button. + """ + self.buttonBox.button(QDialogButtonBox.Ok).setEnabled( + bool(self.nameEdit.text())) @pyqtSlot(str) - def on_nameEdit_textChanged(self, p0): + def on_nameEdit_textChanged(self, txt): """ - Slot documentation goes here. + Private slot to handle changes of the name. - @param p0 DESCRIPTION + @param txt current text of the name edit @type str """ - # TODO: not implemented yet - raise NotImplementedError + self.__updateOkButton() + + def getData(self): + """ + Public method to get the entered data. + + @return tuple containing the variable name and value + @rtype tuple of (str, str) + """ + return ( + self.nameEdit.text().strip(), + self.valueEdit.text().strip(), + )