def check_value(self, value): """Override DataItem method""" if not self.get_prop('data', 'check_value', True): return True if not isinstance(value, self.type): return False from guidata.qthelpers import text_to_qcolor return text_to_qcolor(value).isValid()
def check_value(self, value): """Override DataItem method""" if not self.get_prop('data', 'check_value', True): return True if not isinstance(value, self.type): return False from guidata.qthelpers import text_to_qcolor return text_to_qcolor(value).isValid()
def select_color(self): """Open a color selection dialog box""" color = text_to_qcolor(self.edit.text()) if not color.isValid(): color = Qt.gray color = QColorDialog.getColor(color, self.parent_layout.parent) if color.isValid(): value = color.name() self.edit.setText(value) self.update(value)
def update(self, value): """Reimplement LineEditWidget method""" LineEditWidget.update(self, value) color = text_to_qcolor(value) if color.isValid(): bitmap = QPixmap(16, 16) bitmap.fill(color) icon = QIcon(bitmap) else: icon = get_icon("not_found") self.button.setIcon(icon)
def update(self, value): """Reimplement LineEditWidget method""" super().update(value) color = text_to_qcolor(value) if color.isValid(): bitmap = QtGui.QPixmap(16, 16) bitmap.fill(color) icon = QtGui.QIcon(bitmap) else: icon = qta.icon("mdi.card-outline") self.button.setIcon(icon)