Ejemplo n.º 1
0
def showColorWheel(self, event=None):
    '''Show a Qt color dialog.'''
    c = self.c; p = c.p
    picker = QtWidgets.QColorDialog()
    in_color_setting = p.h.startswith('@color ')
    try:
        text = QtWidgets.QApplication.clipboard().text()
        if in_color_setting:
            text = p.h.split('=', 1)[1].strip()
        color = QtGui.QColor(text)
        picker.setCurrentColor(color)
    except (ValueError, IndexError) as e:
        g.trace('error caught', e)
    if not picker.exec_():
        g.es("No color selected")
    elif in_color_setting:
        udata = c.undoer.beforeChangeNodeContents(p)
        p.h = '%s = %s' % (
            p.h.split('=', 1)[0].strip(),
            picker.selectedColor().name(),
        )
        c.undoer.afterChangeNodeContents(p, 'change-color', udata)
    else:
        text = picker.selectedColor().name()
        g.es("copied to clipboard:", text)
        QtWidgets.QApplication.clipboard().setText(text)
Ejemplo n.º 2
0
def showColorWheel(event=None):
    '''Show a Qt color dialog.'''
    picker = QtWidgets.QColorDialog()
    try:
        text = QtWidgets.QApplication.clipboard().text()
        color = QtGui.QColor(text)
        picker.setCurrentColor(color)
    except ValueError:
        pass
    if not picker.exec_():
        g.es("No color selected")
    else:
        text = picker.selectedColor().name()
        g.es("copied to clipboard:", text)
        QtWidgets.QApplication.clipboard().setText(text)