diff -r e9e7eca7efee -r bf71ee032bb4 src/eric7/EricWidgets/EricComboSelectionDialog.py --- a/src/eric7/EricWidgets/EricComboSelectionDialog.py Wed Jul 13 11:16:20 2022 +0200 +++ b/src/eric7/EricWidgets/EricComboSelectionDialog.py Wed Jul 13 14:55:47 2022 +0200 @@ -17,10 +17,11 @@ """ Class implementing a dialog to select one entry from a list of strings. """ + def __init__(self, entries, title="", message="", parent=None): """ Constructor - + @param entries list of entries to select from @type list of str or list of tuples of (str, any) @param title title of the dialog (defaults to "") @@ -32,38 +33,36 @@ """ super().__init__(parent) self.setupUi(self) - + for entry in entries: if isinstance(entry, tuple): self.selectionComboBox.addItem(*entry) else: self.selectionComboBox.addItem(entry) - - self.on_selectionComboBox_currentTextChanged( - self.selectionComboBox.itemText(0)) - + + self.on_selectionComboBox_currentTextChanged(self.selectionComboBox.itemText(0)) + msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height()) - + @pyqtSlot(str) def on_selectionComboBox_currentTextChanged(self, txt): """ Private slot to react upon changes of the selected entry. - + @param txt text of the selected entry @type str """ - self.buttonBox.button( - QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt)) - + self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(bool(txt)) + def getSelection(self): """ Public method to retrieve the selected item and its data. - + @return tuple containing the selected entry and its associated data @rtype tuple of (str, any) """ return ( self.selectionComboBox.currentText(), - self.selectionComboBox.currentData() + self.selectionComboBox.currentData(), )