def btnLabelColorClick(self): dlgColor = QColorDialog(self) dlgColor.setCurrentColor(self.selectedLabelItem.fontColor()) result = dlgColor.exec_() if result == 1: self.labelColor = dlgColor.selectedColor() self.selectedLabelItem.setFontColor(self.labelColor)
class ColorPicker(QWidget): """A widget that shows a colored box and pops up a color dialog.""" def __init__(self, plot_config): QWidget.__init__(self) self.plot_config = plot_config self.color_dialog = QColorDialog() size = 20 self.setMaximumSize(QSize(size, size)) self.setMinimumSize(QSize(size, size)) self.setToolTip("Click to change color!") def paintEvent(self, paintevent): """Paints the box""" painter = QPainter(self) rect = self.contentsRect() rect.setWidth(rect.width() - 1) rect.setHeight(rect.height() - 1) painter.drawRect(rect) rect.setX(rect.x() + 1) rect.setY(rect.y() + 1) painter.fillRect(rect, self._getColor()) def _setColor(self, color): """Set the color of this picker.""" self.plot_config.color = (color.redF(), color.greenF(), color.blueF()) self.update() def _getColor(self): """Return the color of this picker as QColor.""" color = self.plot_config.color return QColor(int(color[0] * 255), int(color[1] * 255), int(color[2] * 255)) def mouseDoubleClickEvent(self, event): self.color_dialog.setCurrentColor(self._getColor()) status = self.color_dialog.exec_() if status == QDialog.Accepted: self._setColor(self.color_dialog.selectedColor()) def mousePressEvent(self, event): self.color_dialog.setCurrentColor(self._getColor()) status = self.color_dialog.exec_() if status == QDialog.Accepted: self._setColor(self.color_dialog.selectedColor())
def change_color(self, index): color = self.model().data(index, ColorRole) if color is None: return dlg = QColorDialog(QColor(*color)) if dlg.exec(): color = dlg.selectedColor() self.model().setData(index, color.getRgb(), ColorRole)
def change_color(self, index): color = self.model().data(index, ColorRole) if color is None: return dlg = QColorDialog(QColor(*color)) if dlg.exec(): color = dlg.selectedColor() self.model().setData(index, color.getRgb(), ColorRole)
def selectColour(): colour = colourAttr.getInstance(self._currentScheme) currentColour = getattr(colour, colourType) colourDialog = QColorDialog(currentColour, self) if colourDialog.exec_(): selected = colourDialog.selectedColor() if selected != currentColour: self._styleButton(button, selected) setattr(colour, colourType, selected)
def selectColour(): colour = colourAttr.getInstance(self._currentScheme) currentColour = getattr(colour, colourType) colourDialog = QColorDialog(currentColour, self) if colourDialog.exec_(): selected = colourDialog.selectedColor() if selected != currentColour: self._styleButton(button, selected) setattr(colour, colourType, selected)
def change_color(self, index): """Invoke palette editor and set the color""" color = self.model().data(index, ColorRole) if color is None: return dlg = QColorDialog(QColor(*color)) if dlg.exec(): color = dlg.selectedColor() self.model().setData(index, color.getRgb(), ColorRole)
def on_cameraFrameToolButton_clicked(self): """ Slot documentation goes here. """ frameColorDialog = QColorDialog(self) if frameColorDialog.exec_() == QDialog.Accepted: frameColorName = str(frameColorDialog.selectedColor().name()) self.cameraFrameColorWidget.setStyleSheet("QWidget { background-color: %s }" % frameColorName) self.svgbuild.setSingleOption('frame', frameColorName)
def on_backgroundToolButton_clicked(self): """ Slot documentation goes here. """ backgroundColorDialog = QColorDialog(self) if backgroundColorDialog.exec_() == QDialog.Accepted: backgroundColorName = str(backgroundColorDialog.selectedColor().name()) self.backgroundColorWidget.setStyleSheet("QWidget { background-color: %s }" % backgroundColorName) self.svgbuild.setSingleOption('background', backgroundColorName)
def on_lineToolButton_clicked(self): """ Slot documentation goes here. """ lineColorDialog = QColorDialog(self) if lineColorDialog.exec_() == QDialog.Accepted: self.lineColorName = str(lineColorDialog.selectedColor().name()) self.lineColorWidget.setStyleSheet("QWidget { background-color: %s }" % self.lineColorName) self.svgbuild.setSingleOption('line', self.lineColorName)
def change_color(self, index): """Invoke palette editor and set the color""" color = self.model().data(index, ColorRole) if color is None: return dlg = QColorDialog(QColor(*color)) if dlg.exec(): color = dlg.selectedColor() self.model().setData(index, color.getRgb(), ColorRole)
def getColor( parent = None, title = "", color = None, alpha = False, ): """Ask the user a color.""" global _savedColor if color is None: color = _savedColor dlg = QColorDialog(color, parent) options = QColorDialog.ColorDialogOptions() if alpha: options |= QColorDialog.ShowAlphaChannel if not QSettings().value("native_dialogs/colordialog", True, bool): options |= QColorDialog.DontUseNativeDialog dlg.setOptions(options) dlg.setWindowTitle(title or app.caption(_("Select Color"))) if dlg.exec_(): _savedColor = dlg.selectedColor() return _savedColor
def getColor( parent=None, title="", color=None, alpha=False, ): """Ask the user a color.""" global _savedColor if color is None: color = _savedColor dlg = QColorDialog(color, parent) options = QColorDialog.ColorDialogOptions() if alpha: options |= QColorDialog.ShowAlphaChannel if not QSettings().value("native_dialogs/colordialog", True, bool): options |= QColorDialog.DontUseNativeDialog dlg.setOptions(options) dlg.setWindowTitle(title or app.caption(_("Select Color"))) if dlg.exec_(): _savedColor = dlg.selectedColor() return _savedColor
def _on_pick_tree(self, event): """a matplotlib callback function for when a tree is clicked on""" if event.artist != self._treepoints: # print "you clicked on something other than a node" return True ind = event.ind[0] self.tree_selected = self._tree_list[ind] print "tree clicked on", self.tree_selected # launch a color selector dialog and color # all subtrees by the selected color color_dialog = QColorDialog(parent=self) color_dialog.exec_() if color_dialog.result(): color = color_dialog.selectedColor() rgba = color.getRgbF() # red green blue alpha print "color", rgba rgb = rgba[:3] for tree in self.tree_selected.get_all_trees(): tree.data["colour"] = rgb self.redraw_disconnectivity_graph()
def _on_pick_tree(self, event): """a matplotlib callback function for when a tree is clicked on""" if event.artist != self._treepoints: # print "you clicked on something other than a node" return True ind = event.ind[0] self.tree_selected = self._tree_list[ind] print "tree clicked on", self.tree_selected # launch a color selector dialog and color # all subtrees by the selected color color_dialog = QColorDialog(parent=self) color_dialog.exec_() if color_dialog.result(): color = color_dialog.selectedColor() rgba = color.getRgbF() # red green blue alpha print "color", rgba rgb = rgba[:3] for tree in self.tree_selected.get_all_trees(): tree.data["colour"] = rgb self.redraw_disconnectivity_graph()
class ColorChooser(QLabel): def __init__(self, parent=None): QLabel.__init__(self, parent) self.colorDialog = QColorDialog() self.setToolTip("Choose section color") self.selectedColor = "white" self.updateLabelColor() def mousePressEvent(self, QMouseEvent): self.colorDialog.exec_() self.selectedColor = self.colorDialog.selectedColor().name() self.updateLabelColor() def updateLabelColor(self): styleSheet = "background-color:" + self.selectedColor + ";" styleSheet += "border-radius:7px" self.setStyleSheet(styleSheet) def getSelectedColor(self): return self.selectedColor def setColor(self, color): self.selectedColor = color self.updateLabelColor()
class ColorChooser(QLabel): def __init__(self, parent=None): QLabel.__init__(self, parent) self.colorDialog = QColorDialog() self.setToolTip("Choose section color") self.selectedColor = "white" self.updateLabelColor() def mousePressEvent(self, QMouseEvent): self.colorDialog.exec_() self.selectedColor = self.colorDialog.selectedColor().name() self.updateLabelColor() def updateLabelColor(self): styleSheet = "background-color:" + self.selectedColor + ";" styleSheet += "border-radius:7px" self.setStyleSheet(styleSheet) def getSelectedColor(self): return self.selectedColor def setColor(self, color): self.selectedColor = color self.updateLabelColor()
def SetProductColour(self): picker = QColorDialog() picker.exec_() if picker.selectedColor() is not None: self._CurrentReaction.SetProductColour(picker.selectedColor())