当前位置: 首页>>代码示例>>Python>>正文


Python QColorDialog.currentColor方法代码示例

本文整理汇总了Python中PyQt5.QtWidgets.QColorDialog.currentColor方法的典型用法代码示例。如果您正苦于以下问题:Python QColorDialog.currentColor方法的具体用法?Python QColorDialog.currentColor怎么用?Python QColorDialog.currentColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt5.QtWidgets.QColorDialog的用法示例。


在下文中一共展示了QColorDialog.currentColor方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mouseDoubleClickEvent

# 需要导入模块: from PyQt5.QtWidgets import QColorDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QColorDialog import currentColor [as 别名]
 def mouseDoubleClickEvent(self, event):
     if self._readOnly:
         return
     dialog = QColorDialog(self._color)
     dialog.setOptions(QColorDialog.ShowAlphaChannel)
     ok = dialog.exec_()
     if ok:
         self.setColor(dialog.currentColor())
         self.colorChanged.emit()
开发者ID:pathumego,项目名称:trufont,代码行数:11,代码来源:colorWidgets.py

示例2: pickColor

# 需要导入模块: from PyQt5.QtWidgets import QColorDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QColorDialog import currentColor [as 别名]
 def pickColor(self):
     if self._readOnly:
         return
     dialog = QColorDialog(self._color)
     dialog.setOptions(QColorDialog.ShowAlphaChannel)
     ok = dialog.exec_()
     if ok:
         self.setColor(dialog.currentColor())
         self.colorChanged.emit()
开发者ID:davelab6,项目名称:trufont,代码行数:11,代码来源:colorWidgets.py

示例3: mouseDoubleClickEvent

# 需要导入模块: from PyQt5.QtWidgets import QColorDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QColorDialog import currentColor [as 别名]
 def mouseDoubleClickEvent(self, event):
     event.accept()
     if self._readOnly:
         return
     dialog = QColorDialog()
     ok = dialog.exec_()
     if ok:
         self.setColor(dialog.currentColor())
         self.colorChanged.emit()
开发者ID:paarandika,项目名称:trufont,代码行数:11,代码来源:colorWidgets.py

示例4: _doubleClicked

# 需要导入模块: from PyQt5.QtWidgets import QColorDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QColorDialog import currentColor [as 别名]
 def _doubleClicked(self, index):
     model = self.model()
     if model is None:
         return
     data = model.data(index)
     if isinstance(data, QColor):
         if QApplication.keyboardModifiers() & Qt.AltModifier:
             model.setData(index, QColor())
         else:
             dialog = QColorDialog(self)
             dialog.setCurrentColor(data)
             dialog.setOption(QColorDialog.ShowAlphaChannel)
             ret = dialog.exec_()
             if ret:
                 color = dialog.currentColor()
                 model.setData(index, color)
开发者ID:adrientetar,项目名称:defconQt,代码行数:18,代码来源:listView.py

示例5: ColorPanel

# 需要导入模块: from PyQt5.QtWidgets import QColorDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QColorDialog import currentColor [as 别名]
class ColorPanel(QGraphicsItem):
    _scaf_colors = styles.SCAF_COLORS
    _stap_colors = styles.STAP_COLORS
    _PEN = Qt.NoPen

    def __init__(self, parent=None):
        super(ColorPanel, self).__init__(parent)
        self.rect = QRectF(0, 0, 30, 30)
        self.setFlag(QGraphicsItem.ItemIgnoresTransformations)
        self.colordialog = QColorDialog()
        # self.colordialog.setOption(QColorDialog.DontUseNativeDialog)
        self._scaf_color_index = -1  # init on -1, painttool will cycle to 0
        self._stap_color_index = -1  # init on -1, painttool will cycle to 0
        self._scaf_color = self._scaf_colors[self._scaf_color_index]
        self._stap_color = self._stap_colors[self._stap_color_index]
        self._scaf_brush = QBrush(self._scaf_color)
        self._stap_brush = QBrush(self._stap_color)
        self._initLabel()
        self.hide()

    def _initLabel(self):
        self._label = label = QGraphicsSimpleTextItem("scaf\nstap", parent=self)
        label.setPos(32, 0)
        label.setFont(_FONT)
        # label.setBrush(_labelbrush)
        # label.hide()

    def boundingRect(self):
        return self.rect

    def paint(self, painter, option, widget=None):
        painter.setPen(self._PEN)
        painter.setBrush(self._scaf_brush)
        painter.drawRect(0, 0, 30, 15)
        painter.setBrush(self._stap_brush)
        painter.drawRect(0, 15, 30, 15)

    def nextColor(self):
        self._stap_color_index += 1
        if self._stap_color_index == len(self._stap_colors):
            self._stap_color_index = 0
        self._stap_color = self._stap_colors[self._stap_color_index]
        self._stap_brush.setColor(self._stap_color)
        self.update()

    def prevColor(self):
        self._stap_color_index -= 1

    def color(self):
        return self._stap_color

    def scafColorName(self):
        return self._scaf_color.name()

    def stapColorName(self):
        return self._stap_color.name()

    def changeScafColor(self):
        self.update()

    def changeStapColor(self):
        self._stap_color = self.colordialog.currentColor()
        self._stap_brush = QBrush(self._stap_color)
        self.update()

    def mousePressEvent(self, event):
        if event.pos().y() < 10:
            new_color = self.colordialog.getColor(self._scaf_color)
            if new_color.isValid() and new_color.name() != self._scaf_color.name():
                self._scaf_color = new_color
                self._scaf_brush = QBrush(new_color)
                if not new_color in self._scaf_colors:
                    self._scaf_colors.insert(self._scaf_color_index, new_color)
                self.update()
        else:
            new_color = self.colordialog.getColor(self._stap_color)
            if new_color.isValid() and new_color.name() != self._stap_color.name():
                self._stap_color = new_color
                self._stap_brush = QBrush(new_color)
                if not new_color in self._stap_colors:
                    self._stap_colors.insert(self._stap_color_index, new_color)
                self.update()
开发者ID:Rebelofold,项目名称:cadnano2.5,代码行数:84,代码来源:colorpanel.py

示例6: onColorPicker

# 需要导入模块: from PyQt5.QtWidgets import QColorDialog [as 别名]
# 或者: from PyQt5.QtWidgets.QColorDialog import currentColor [as 别名]
    def onColorPicker(self):
        dialog = QColorDialog()
        dialog.setCurrentColor(self._color)

        if dialog.exec_():
            self.set_color(dialog.currentColor())
开发者ID:Tinkerforge,项目名称:brickv,代码行数:8,代码来源:rgb_led_matrix.py


注:本文中的PyQt5.QtWidgets.QColorDialog.currentColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。