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


Python QtGui.QColor方法代码示例

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


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

示例1: mouseMoveEvent

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def mouseMoveEvent(self, event):
        self.unhighlight()
        scenePos = self.mapToScene(event.pos())

        # When clicking on an UI port label, it is ambigous which connection point should be activated.
        # We let the user drag the mouse in either direction to select the conneciton point to activate.
        delta = scenePos - self.__mousDownPos
        if delta.x() < 0:
            if self.__port.inCircle() is not None:
                self.__port.inCircle().mousePressEvent(event)
        else:
            if self.__port.outCircle() is not None:
                self.__port.outCircle().mousePressEvent(event)

    # def paint(self, painter, option, widget):
    #     super(PortLabel, self).paint(painter, option, widget)
    #     painter.setPen(QtGui.QPen(QtGui.QColor(0, 0, 255)))
    #     painter.drawRect(self.windowFrameRect()) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:20,代码来源:port.py

示例2: mousePressEvent

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def mousePressEvent(self, event):

        self.unhighlight()

        scenePos = self.mapToScene(event.pos())

        from .mouse_grabber import MouseGrabber
        if self.isInConnectionPoint():
            MouseGrabber(self._graph, scenePos, self, 'Out')
        elif self.isOutConnectionPoint():
            MouseGrabber(self._graph, scenePos, self, 'In')


    # def paint(self, painter, option, widget):
    #     super(PortCircle, self).paint(painter, option, widget)
    #     painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 0)))
    #     painter.drawRect(self.windowFrameRect()) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:19,代码来源:port.py

示例3: generateNodes

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def generateNodes(count, offset, depth):
    for i in range(count):
        node1 = Node(graph, 'node' + str(depth) + str(i))
        node1.addPort(InputPort(node1, graph, 'InPort', QtGui.QColor(128, 170, 170, 255), 'MyDataX'))
        node1.addPort(OutputPort(node1, graph, 'OutPort', QtGui.QColor(32, 255, 32, 255), 'MyDataX'))
        node1.setGraphPos(QtCore.QPointF(offset, i * 80 ))

        graph.addNode(node1)

        global totalCount
        totalCount += 1

    if depth < 6:
        generateNodes( count * 2, offset+160, depth+1)

        for i in range(count):
            graph.connectPorts('node' + str(depth) + str(i), 'OutPort', 'node' + str(depth+1) + str(i*2), 'InPort')
            graph.connectPorts('node' + str(depth) + str(i), 'OutPort', 'node' + str(depth+1) + str(i*2+1), 'InPort')
    elif depth < 12:
        generateNodes( int(count / 2), offset+160, depth+1)

        for i in range(count//2):
            graph.connectPorts('node' + str(depth) + str(i), 'OutPort', 'node' + str(depth+1) + str(int(i)), 'InPort') 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:25,代码来源:bigGraph.py

示例4: data_internal

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def data_internal(self, index, record, role):
        result = None
        if role == Qt.DisplayRole:
            if index.column() == self.columnCount(INVALID_INDEX) - 1:
                result = record._cutelog
            else:
                column = self.table_header[index.column()]
                if column.name == 'asctime':
                    result = record.asctime
        elif role == Qt.SizeHintRole:
            result = QSize(1, CONFIG.logger_row_height)
        elif role == Qt.FontRole:
            result = QFont(CONFIG.logger_table_font, CONFIG.logger_table_font_size)
        elif role == Qt.ForegroundRole:
            if not self.dark_theme:
                result = QColor(Qt.black)
            else:
                result = QColor(Qt.white)
        elif role == Qt.BackgroundRole:
            if not self.dark_theme:
                color = QColor(Qt.lightGray)
            else:
                color = QColor(Qt.darkGray)
            result = QBrush(color, Qt.BDiagPattern)
        return result 
开发者ID:busimus,项目名称:cutelog,代码行数:27,代码来源:logger_tab.py

示例5: openDialog

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def openDialog(self):
        """ open a color choosed dialog """
        if self.color in self.maps:
            dialog = ColorMapChoose(self.parent(), self.color)
            colormap, selected = dialog.exec()
            if selected is False:
                return
            self.setColor(colormap)
        else:
            # get new color from color picker
            qcolor = QtGui.QColor(*np.array(mpl.colors.to_rgb(self.getColor())) * 255)
            color = QtWidgets.QColorDialog.getColor(qcolor, self.parent())
            # if a color is set, apply it
            if color.isValid():
                color = "#%02x%02x%02x" % color.getRgb()[:3]
                self.setColor(color) 
开发者ID:rgerum,项目名称:pylustrator,代码行数:18,代码来源:QtShortCuts.py

示例6: setColor

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def setColor(self, color: AnyColorType) -> None:
        """Set the color of the swatch.

        Parameters
        ----------
        color : ColorType
            Can be any ColorType recognized by our
            utils.colormaps.standardize_color.transform_color function.
        """
        if isinstance(color, QColor):
            _color = (np.array(color.getRgb()) / 255).astype(np.float32)
        else:
            try:
                _color = transform_color(color)[0]
            except ValueError:
                return self.color_changed.emit(self._color)
        emit = np.any(self._color != _color)
        self._color = _color
        if emit or np.all(_color == TRANSPARENT):
            self.color_changed.emit(_color) 
开发者ID:napari,项目名称:napari,代码行数:22,代码来源:qt_color_dialog.py

示例7: __init__

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def __init__(
        self, parent: QWidget = None, initial_color: AnyColorType = None
    ) -> None:
        super().__init__(parent)
        self.setObjectName('QtColorPopup')
        self.color_dialog = CustomColorDialog(self)

        # native dialog doesn't get added to the QtPopup frame
        # so more would need to be done to use it
        self.color_dialog.setOptions(
            QColorDialog.DontUseNativeDialog | QColorDialog.ShowAlphaChannel
        )
        layout = QVBoxLayout()
        self.frame.setLayout(layout)
        layout.addWidget(self.color_dialog)

        self.color_dialog.currentColorChanged.connect(
            self.currentColorChanged.emit
        )
        self.color_dialog.colorSelected.connect(self._on_color_selected)
        self.color_dialog.rejected.connect(self._on_rejected)
        self.color_dialog.setCurrentColor(QColor(initial_color)) 
开发者ID:napari,项目名称:napari,代码行数:24,代码来源:qt_color_dialog.py

示例8: __init__

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def __init__(self, text_edit):
        """ Create a call tip manager that is attached to the specified Qt
            text edit widget.
        """
        assert isinstance(text_edit, (QtWidgets.QTextEdit, QtWidgets.QPlainTextEdit))
        super(BracketMatcher, self).__init__()

        # The format to apply to matching brackets.
        self.format = QtGui.QTextCharFormat()
        self.format.setBackground(QtGui.QColor('silver'))

        self._text_edit = text_edit
        text_edit.cursorPositionChanged.connect(self._cursor_position_changed)

    #--------------------------------------------------------------------------
    # Protected interface
    #-------------------------------------------------------------------------- 
开发者ID:jupyter,项目名称:qtconsole,代码行数:19,代码来源:bracket_matcher.py

示例9: __init__

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def __init__(self, graph, srcPortCircle, dstPortCircle):
        super(Connection, self).__init__()

        self.__graph = graph
        self.__srcPortCircle = srcPortCircle
        self.__dstPortCircle = dstPortCircle
        penStyle = QtCore.Qt.DashLine

        self.__connectionColor = QtGui.QColor(0, 0, 0)
        self.__connectionColor.setRgbF(*self.__srcPortCircle.getColor().getRgbF())
        self.__connectionColor.setAlpha(125)

        self.__defaultPen = QtGui.QPen(self.__connectionColor, 1.5, style=penStyle)
        self.__defaultPen.setDashPattern([1, 2, 2, 1])

        self.__connectionHoverColor = QtGui.QColor(0, 0, 0)
        self.__connectionHoverColor.setRgbF(*self.__srcPortCircle.getColor().getRgbF())
        self.__connectionHoverColor.setAlpha(255)

        self.__hoverPen = QtGui.QPen(self.__connectionHoverColor, 1.5, style=penStyle)
        self.__hoverPen.setDashPattern([1, 2, 2, 1])

        self.setPen(self.__defaultPen)
        self.setZValue(-1)

        self.setAcceptHoverEvents(True)
        self.connect() 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:29,代码来源:connection.py

示例10: __init__

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def __init__(self, port, graph, hOffset, color, connectionPointType):
        super(PortCircle, self).__init__(port)

        self.__port = port
        self._graph = graph
        self._connectionPointType = connectionPointType
        self.__connections = set()
        self._supportsOnlySingleConnections = connectionPointType == 'In'

        self.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed))
        size = QtCore.QSizeF(self.__diameter, self.__diameter)
        self.setPreferredSize(size)
        self.setWindowFrameMargins(0, 0, 0, 0)

        self.transform().translate(self.__radius * hOffset, 0)

        self.__defaultPen = QtGui.QPen(QtGui.QColor(25, 25, 25), 1.0)
        self.__hoverPen = QtGui.QPen(QtGui.QColor(255, 255, 100), 1.5)

        self._ellipseItem = QtWidgets.QGraphicsEllipseItem(self)
        self._ellipseItem.setPen(self.__defaultPen)
        self._ellipseItem.setPos(size.width()/2, size.height()/2)
        self._ellipseItem.setRect(
            -self.__radius,
            -self.__radius,
            self.__diameter,
            self.__diameter,
            )
        if connectionPointType == 'In':
            self._ellipseItem.setStartAngle(270 * 16)
            self._ellipseItem.setSpanAngle(180 * 16)

        self.setColor(color)
        self.setAcceptHoverEvents(True) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:36,代码来源:port.py

示例11: setItem

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def setItem(self, item):
        item.setParentItem(self)
        self.layout().addItem(item)

    # def paint(self, painter, option, widget):
    #     super(ItemHolder, self).paint(painter, option, widget)
    #     painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 0)))
    #     painter.drawRect(self.windowFrameRect()) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:10,代码来源:port.py

示例12: textSize

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def textSize(self):
        return QtCore.QSizeF(
            self.__textItem.textWidth(),
            self.__font.pointSizeF() + self.__labelBottomSpacing
            )

    # def paint(self, painter, option, widget):
    #     super(NodeTitle, self).paint(painter, option, widget)
    #     painter.setPen(QtGui.QPen(QtGui.QColor(0, 255, 0)))
    #     painter.drawRect(self.windowFrameRect()) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:12,代码来源:node.py

示例13: setText

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def setText(self, text):
        self._titleWidget.setText(text)

    # def paint(self, painter, option, widget):
    #     super(NodeHeader, self).paint(painter, option, widget)
    #     painter.setPen(QtGui.QPen(QtGui.QColor(0, 255, 100)))
    #     painter.drawRect(self.windowFrameRect()) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:9,代码来源:node.py

示例14: addPort

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def addPort(self, port, alignment):
        layout = self.layout()
        layout.addItem(port)
        layout.setAlignment(port, alignment)
        self.adjustSize()
        return port

    # def paint(self, painter, option, widget):
    #     super(PortList, self).paint(painter, option, widget)
    #     painter.setPen(QtGui.QPen(QtGui.QColor(255, 255, 0)))
    #     painter.drawRect(self.windowFrameRect()) 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:13,代码来源:node.py

示例15: paint

# 需要导入模块: from qtpy import QtGui [as 别名]
# 或者: from qtpy.QtGui import QColor [as 别名]
def paint(self, painter, option, widget):
        rect = self.windowFrameRect()
        painter.setBrush(self.__color)

        painter.setPen(QtGui.QPen(QtGui.QColor(0, 0, 0, 0), 0))

        roundingY = 10
        roundingX = 10

        painter.drawRoundedRect(rect, roundingX, roundingY)

        # Title BG
        titleHeight = self.__headerItem.size().height() - 3

        painter.setBrush(self.__color.darker(125))
        roundingY = rect.width() * roundingX / titleHeight
        painter.drawRoundedRect(0, 0, rect.width(), titleHeight, roundingX, roundingY, QtCore.Qt.AbsoluteSize)
        painter.drawRect(0, titleHeight * 0.5 + 2, rect.width(), titleHeight * 0.5)

        painter.setBrush(QtGui.QColor(0, 0, 0, 0))
        if self.__selected:
            painter.setPen(self.__selectedPen)
        else:
            painter.setPen(self.__unselectedPen)

        roundingY = 10
        roundingX = 10

        painter.drawRoundedRect(rect, roundingX, roundingY, QtCore.Qt.AbsoluteSize)


    #########################
    ## Events 
开发者ID:EricTRocks,项目名称:pyflowgraph,代码行数:35,代码来源:node.py


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