Example #1
0
    def __init__(self, init_color, parent=None):
        super(MColorPaletteDialog, self).__init__(parent)
        self.setWindowTitle("DAYU Color Palette")
        self.primary_color = QtGui.QColor(init_color)
        self.color_chart = MColorChart()
        self.choose_color_button = QtWidgets.QPushButton()
        self.choose_color_button.setFixedSize(QtCore.QSize(100, 30))
        self.color_label = QtWidgets.QLabel()
        self.info_label = MLabel()
        self.info_label.setProperty("error", True)
        color_lay = QtWidgets.QHBoxLayout()
        color_lay.addWidget(MLabel("Primary Color:"))
        color_lay.addWidget(self.choose_color_button)
        color_lay.addWidget(self.color_label)
        color_lay.addWidget(self.info_label)
        color_lay.addStretch()
        dialog = QtWidgets.QColorDialog(self.primary_color, parent=self)
        dialog.setWindowFlags(QtCore.Qt.Widget)
        dialog.setOption(QtWidgets.QColorDialog.NoButtons)
        dialog.currentColorChanged.connect(self.slot_color_changed)
        setting_lay = QtWidgets.QVBoxLayout()
        setting_lay.addLayout(color_lay)
        setting_lay.addWidget(MDivider())
        setting_lay.addWidget(dialog)

        main_lay = QtWidgets.QHBoxLayout()
        main_lay.addWidget(self.color_chart)
        main_lay.addLayout(setting_lay)
        self.setLayout(main_lay)
        self.update_color()
Example #2
0
    def pickCustomColor(self):
        palette = self.uiCustomBTN.palette()
        qcolor = palette.color(QtGui.QPalette.Button)

        colorDialog = QtWidgets.QColorDialog(qcolor, self)
        if not colorDialog.exec_():
            return

        self.setColor(colorDialog.currentColor())
Example #3
0
    def change_color(self):
        dialog = QtWidgets.QColorDialog()
        cursor = QtGui.QCursor()
        dialog.move(cursor.pos())
        dialog.setCurrentColor(self._color)
        newColor = dialog.getColor(self._color)

        if newColor != self._color:
            self.set_color(newColor)
Example #4
0
    def colorPickerDialog(self, current_color=None):
        """ Opens a system dialog for choosing a colour.
			Return the selected colour as a QColor object, or None if the
			dialog is cancelled.
		"""
        color_dialog = QtWidgets.QColorDialog()
        #color_dialog.setOption(QtWidgets.QColorDialog.DontUseNativeDialog)

        # Set current colour
        if current_color is not None:
            color_dialog.setCurrentColor(current_color)

        # Only return a color if valid / dialog accepted
        if color_dialog.exec_() == color_dialog.Accepted:
            color = color_dialog.selectedColor()
            return color
Example #5
0
    def __init__(self, label=None, color=None, parent=None):
        super(ColorSelectionButton, self).__init__(parent)
        self.label = label

        self._color = color
        self._init_color = color

        self.painter = QtGui.QPainter()

        self.mouse_pressed = False

        self.text_options = QtGui.QTextOption()
        self.text_options.setAlignment(QtCore.Qt.AlignCenter)

        self.pressed.connect(self.on_color_picker)

        self.dlg = QtWidgets.QColorDialog(QtGui.QColor(128, 255, 64))
        self.dlg.setOption(QtWidgets.QColorDialog.ShowAlphaChannel, on=True)

        self.setMouseTracking(True)
        self.state = ColorSelectionButton.NORMAL
        self.installEventFilter(self)