--- a/ProjectDjangoTagsMenu/DjangoTagInputDialog.py Sat May 29 15:04:13 2021 +0200 +++ b/ProjectDjangoTagsMenu/DjangoTagInputDialog.py Sun May 30 11:51:44 2021 +0200 @@ -7,10 +7,10 @@ Module implementing a dialog to enter data for the creation of a tag. """ -from PyQt5.QtCore import Qt -from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel - -from E5Gui.E5LineEdit import E5ClearableLineEdit +from PyQt6.QtCore import Qt +from PyQt6.QtWidgets import ( + QDialog, QDialogButtonBox, QVBoxLayout, QLabel, QLineEdit +) class DjangoTagInputDialog(QDialog): @@ -21,10 +21,12 @@ """ Constructor - @param labels list of labels for the entry fields (list of string) - @param defaults list of default values for the entry fields (list - of string) - @param parent reference to the parent widget (QWidget) + @param labels list of labels for the entry fields + @type list of str + @param defaults list of default values for the entry fields + @type list of str + @param parent reference to the parent widget + @type QWidget @exception RuntimeError raised to signal too many labels were given """ super().__init__(parent) @@ -38,14 +40,18 @@ self.__topLayout = QVBoxLayout(self) for index, label in enumerate(labels): self.__topLayout.addWidget(QLabel(label, self)) - entry = E5ClearableLineEdit(self) + entry = QLineEdit(self) + entry.setClearButtonEnabled(True) if defaults and index < len(defaults): entry.setText(defaults[index]) self.__inputs.append(entry) self.__topLayout.addWidget(entry) self.__buttonBox = QDialogButtonBox( - QDialogButtonBox.Ok | QDialogButtonBox.Cancel, - Qt.Horizontal, self) + QDialogButtonBox.StandardButton.Ok | + QDialogButtonBox.StandardButton.Cancel, + Qt.Orientation.Horizontal, + self + ) self.__topLayout.addWidget(self.__buttonBox) self.resize(400, self.minimumSizeHint().height()) @@ -61,7 +67,8 @@ """ Public method to retrieve the entered data. - @return tuple containing the text of all entries (tuple of string) + @return tuple containing the text of all entries + @rtype tuple of str """ data = [input.text().strip() for input in self.__inputs] return tuple(data) @@ -71,21 +78,24 @@ """ Public static method to create the dialog and return the entered data. - @param parent reference to the parent widget (QWidget) - @param title title of the dialog (string) - @param labels list of labels for the entry fields (list of string) - @param defaults list of default values for the entry fields (list - of string) + @param parent reference to the parent widget + @type QWidget + @param title title of the dialog + @type str + @param labels list of labels for the entry fields + @type list of str + @param defaults list of default values for the entry fields + @type list of str @return tuple of a tuple containing the text of all entries - (tuple of string) and a flag indicating the acceptance - state (boolean) + and a flag indicating the acceptance state + @rtype tuple of (tuple of str, bool) """ if defaults is None: defaults = [] dlg = DjangoTagInputDialog(labels, defaults, parent) dlg.setWindowTitle(title) - if dlg.exec() == QDialog.Accepted: + if dlg.exec() == QDialog.DialogCode.Accepted: return dlg.getData(), True else: return (), False