Python PyQt5.QtWidgets.QColorDialog() Examples

The following are 11 code examples for showing how to use PyQt5.QtWidgets.QColorDialog(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtWidgets , or try the search function .

Example 1
Project: pkmeter   Author: pkkid   File: gcal.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _init_colorpicker(self):
        colorpicker = QtWidgets.QColorDialog()
        colorpicker.finished.connect(self.colorpicker_finished)
        return colorpicker 
Example 2
Project: Lector   Author: BasioMeusPuga   File: annotations.py    License: GNU General Public License v3.0 5 votes vote down vote up
def get_color(self, current_color):
        color_dialog = QtWidgets.QColorDialog()
        new_color = color_dialog.getColor(current_color)
        if new_color.isValid():  # Returned in case cancel is pressed
            return new_color
        else:
            return current_color 
Example 3
Project: ddt4all   Author: cedricp   File: parameters.py    License: GNU General Public License v3.0 5 votes vote down vote up
def changeLabelColor(self):
        if self.currentwidget is None:
            return

        if isinstance(self.currentwidget, displaymod.labelWidget):
            colordialog = widgets.QColorDialog()
            color = colordialog.getColor()
            if color.isValid():
                self.currentwidget.jsondata['color'] = "rgb(%i,%i,%i)" % (color.red(), color.green(), color.blue())

        self.reinitScreen() 
Example 4
Project: kite   Author: pyrocko   File: config.py    License: GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        QtWidgets.QDialog.__init__(self, *args, **kwargs)

        self.completer = QtWidgets.QCompleter()
        self.completer_model = QtWidgets.QFileSystemModel(self.completer)
        self.completer.setModel(self.completer_model)
        self.completer.setMaxVisibleItems(8)

        loadUi(get_resource('dialog_config.ui'), self)

        self.ok_button.released.connect(
            self.setAttributes)
        self.ok_button.released.connect(
            self.close)

        self.apply_button.released.connect(
            self.setAttributes)

        self.vector_color_picker = QtWidgets.QColorDialog(self)
        self.vector_color_picker. \
            setCurrentColor(QtGui.QColor(*getConfig().vector_color))
        self.vector_color_picker. \
            setOption(self.vector_color_picker.ShowAlphaChannel)
        self.vector_color_picker.colorSelected.connect(
            self.updateVectorColor)
        self.vector_color_picker.setModal(True)
        self.vector_color.clicked.connect(
            self.vector_color_picker.show)

        self.vector_color.setValue = self.setButtonColor
        self.vector_color.value = self.getButtonColor

        self.chooseStoreDirButton.released.connect(
            self.chooseStoreDir)
        self.completer_model.setRootPath('')
        self.completer.setParent(self.default_gf_dir)
        self.default_gf_dir.setCompleter(self.completer)

        self.getAttributes() 
Example 5
Project: linux-show-player   Author: FrancescoCeruti   File: qcolorbutton.py    License: GNU General Public License v3.0 5 votes vote down vote up
def onColorPicker(self):
        dlg = QColorDialog()

        if self._color is not None:
            dlg.setCurrentColor(QColor(self._color))
        if dlg.exec_() == dlg.Accepted:
            self.setColor(dlg.currentColor().name()) 
Example 6
Project: Sark   Author: tmr232   File: ui.py    License: MIT License 5 votes vote down vote up
def ask_color(initial=None):
    if initial is not None:
        color = QtGui.QColor(initial & 0xFF, (initial >> 8) & 0xFF, (initial >> 16) & 0xFF)
        qcolor_dialog = QtWidgets.QColorDialog(color)

    else:
        qcolor_dialog = QtWidgets.QColorDialog()

    qcolor = qcolor_dialog.getColor()

    if not qcolor.isValid:
        return None

    return (qcolor.blue() << 16) | (qcolor.green() << 8) | (qcolor.red() << 0) 
Example 7
Project: pychemqt   Author: jjgomera   File: widgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def ColorButtonClicked(self):
        """Show the QColorDialog to let user choose new color"""
        dlg = QtWidgets.QColorDialog(self.color, self)
        if self.isAlpha:
            dlg.setOption(QtWidgets.QColorDialog.ShowAlphaChannel)
        if dlg.exec_():
            self.setColor(dlg.currentColor())
            self.valueChanged.emit(dlg.currentColor().name()) 
Example 8
Project: pychemqt   Author: jjgomera   File: widgets.py    License: GNU General Public License v3.0 5 votes vote down vote up
def colorButtonClicked(self):
        """Show QColorDialog to change the color"""
        dlg = QtWidgets.QColorDialog(self.color, self)
        if dlg.exec_():
            self.setColor(dlg.currentColor()) 
Example 9
Project: pychemqt   Author: jjgomera   File: texteditor.py    License: GNU General Public License v3.0 5 votes vote down vote up
def colordialog(self):
        """Show dialog to choose font color"""
        dialog = QtWidgets.QColorDialog(self.notas.textColor(), self)
        if dialog.exec_():
            self.FontColor.setPalette(QtGui.QPalette(dialog.currentColor()))
            self.notas.setTextColor(dialog.currentColor())
            format = QtGui.QTextCharFormat()
            format.setForeground(dialog.currentColor())
            self.MergeFormat(format) 
Example 10
Project: Mastering-GUI-Programming-with-Python   Author: PacktPublishing   File: three_color_led_gui.py    License: MIT License 5 votes vote down vote up
def __init__(self):
        super().__init__()

        self.tcl = ThreeColorLed(8, 10, 12)
        ccd = qtw.QColorDialog()
        ccd.setOptions(
            qtw.QColorDialog.NoButtons
            | qtw.QColorDialog.DontUseNativeDialog)
        ccd.currentColorChanged.connect(self.set_color)
        self.setCentralWidget(ccd)

        self.show() 
Example 11
Project: Lector   Author: BasioMeusPuga   File: guifunctions.py    License: GNU General Public License v3.0 4 votes vote down vote up
def get_color(self, signal_sender):
        def open_color_dialog(current_color):
            color_dialog = QtWidgets.QColorDialog()
            new_color = color_dialog.getColor(current_color)
            if new_color.isValid():  # Returned in case cancel is pressed
                return new_color
            else:
                return current_color

        # Special cases that don't affect (comic)book display
        if signal_sender == 'libraryBackground':
            current_color = self.settings['listview_background']
            new_color = open_color_dialog(current_color)
            self.listView.setStyleSheet("QListView {{background-color: {0}}}".format(
                new_color.name()))
            self.settings['listview_background'] = new_color
            return

        if signal_sender == 'dialogBackground':
            current_color = self.settings['dialog_background']
            new_color = open_color_dialog(current_color)
            self.settings['dialog_background'] = new_color
            return

        profile_index = self.bookToolBar.profileBox.currentIndex()
        current_profile = self.bookToolBar.profileBox.itemData(
            profile_index, QtCore.Qt.UserRole)

        # Retain current values on opening a new dialog
        if signal_sender == 'fgColor':
            current_color = current_profile['foreground']
            new_color = open_color_dialog(current_color)
            self.bookToolBar.colorBoxFG.setStyleSheet(
                'background-color: %s' % new_color.name())
            current_profile['foreground'] = new_color

        elif signal_sender == 'bgColor':
            current_color = current_profile['background']
            new_color = open_color_dialog(current_color)
            self.bookToolBar.colorBoxBG.setStyleSheet(
                'background-color: %s' % new_color.name())
            current_profile['background'] = new_color

        elif signal_sender == 'comicBGColor':
            current_color = self.comic_profile['background']
            new_color = open_color_dialog(current_color)
            self.bookToolBar.comicBGColor.setStyleSheet(
                'background-color: %s' % new_color.name())
            self.comic_profile['background'] = new_color

        self.bookToolBar.profileBox.setItemData(
            profile_index, current_profile, QtCore.Qt.UserRole)
        self.format_contentView()