--- a/ColorString/ColorSelectionDialog.py Thu Dec 30 12:44:26 2021 +0100 +++ b/ColorString/ColorSelectionDialog.py Wed Sep 21 11:10:49 2022 +0200 @@ -17,10 +17,11 @@ """ Class implementing a dialog to select a color by name. """ + def __init__(self, selectedName="", parent=None): """ Constructor - + @param selectedName name of the color to be selected initially @type str @param parent reference to the parent widget @@ -28,22 +29,23 @@ """ super().__init__(parent) self.setupUi(self) - + for colorName in QColor.colorNames(): - px = QPixmap(22, 22) # icon size 22x22 pixels + px = QPixmap(22, 22) # icon size 22x22 pixels px.fill(QColor(colorName)) self.colorComboBox.addItem(QIcon(px), colorName) if selectedName: self.colorComboBox.setCurrentIndex( - self.colorComboBox.findText(selectedName)) - + self.colorComboBox.findText(selectedName) + ) + msh = self.minimumSizeHint() self.resize(max(self.size().width(), msh.width()), msh.height()) - + def getColor(self): """ Public method to retrieve the selected color name. - + @return color name (string) """ return self.colorComboBox.currentText()