def get_color(self): """ Raise a QColorDialog and apply the color to the background color of the button """ dial = QColorDialog() dial.setOptions(QColorDialog.DontUseNativeDialog) res = dial.exec_() if res: rgb = dial.currentColor().red(), dial.currentColor().green(), dial.currentColor().blue() self.setColor(rgb) rgb = [c / 255.0 for c in rgb] self.colorChanged.emit(rgb)
def get_color(self): """ Raise a QColorDialog and apply the color to the background color of the button """ dial = QColorDialog() dial.setOptions(QColorDialog.DontUseNativeDialog) res = dial.exec_() if res: rgb = dial.currentColor().red(), dial.currentColor().green( ), dial.currentColor().blue() self.setColor(rgb) rgb = [c / 255.0 for c in rgb] self.colorChanged.emit(rgb)
def colorChooserClicked(self, textfield): """ QT Slot handles when a color chooser is clicked. Parameter : - textfield : The QLineEdit where to output the name of the choosen color. """ color = textfield.text() colorChooser = QColorDialog(self) if color: colorChooser.setCurrentColor(QColor(color)) if colorChooser.exec_(): ret = colorChooser.currentColor() if ret is not None and ret.isValid(): color = ret.name() self.updateColorField(textfield, color)