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


Python QtGui.QBrush方法代码示例

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


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

示例1: drawBackground

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def drawBackground(self, painter, rect):
        """
        Draw a grid in the background.

        """
        config = self.parent().config

        self._brush = QtGui.QBrush()
        self._brush.setStyle(QtCore.Qt.SolidPattern)
        self._brush.setColor(utils._convertDataToColor(config['bg_color']))

        painter.fillRect(rect, self._brush)

        if self.views()[0].gridVisToggle:
            leftLine = rect.left() - rect.left() % self.gridSize
            topLine = rect.top() - rect.top() % self.gridSize
            lines = list()

            i = int(leftLine)
            while i < int(rect.right()):
                lines.append(QtCore.QLineF(i, rect.top(), i, rect.bottom()))
                i += self.gridSize

            u = int(topLine)
            while u < int(rect.bottom()):
                lines.append(QtCore.QLineF(rect.left(), u, rect.right(), u))
                u += self.gridSize

            self.pen = QtGui.QPen()
            self.pen.setColor(utils._convertDataToColor(config['grid_color']))
            self.pen.setWidth(0)
            painter.setPen(self.pen)
            painter.drawLines(lines) 
开发者ID:LeGoffLoic,项目名称:Nodz,代码行数:35,代码来源:nodz_main.py

示例2: _createStyle

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def _createStyle(self, parent):
        """
        Read the attribute style from the configuration file.

        """
        config = parent.scene().views()[0].config
        self.brush = QtGui.QBrush()
        self.brush.setStyle(QtCore.Qt.SolidPattern)
        self.brush.setColor(utils._convertDataToColor(config[self.preset]['plug'])) 
开发者ID:LeGoffLoic,项目名称:Nodz,代码行数:11,代码来源:nodz_main.py

示例3: drawWidget

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def drawWidget(self, qp):
        w = self.width()
        h = self.height()

        gradient = QtGui.QLinearGradient(0, 0, w, h)
        for i in range(11):
            hue = self.getHue(i * 0.1)
            gradient.setColorAt(i * 0.1, QtGui.QColor(hue[0] * 255, hue[1] * 255, hue[2] * 255))

        qp.setBrush(QtGui.QBrush(gradient))

        qp.drawRect(0, 0, w, h) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:14,代码来源:QtSliders.py

示例4: __init__

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def __init__(self, raw_ramp, parent=None, bezier=False):
        """
        :param raw_ramp: Core ramp that will perform the interpolation
        :type raw_ramp: :obj:`PyFlow.Core.structs.splineRamp`
        :param parent: Parent QWidget
        :type parent: QtWidgets.QWidget, optional
        :param bezier: Initialize as linear or bezier, defaults to False
        :type bezier: bool, optional
        """
        super(pyf_RampSpline, self).__init__(parent)
        self._rawRamp = raw_ramp
        self.bezier = bezier
        self._scene = QtWidgets.QGraphicsScene(self)
        self.setDragMode(QtWidgets.QGraphicsView.NoDrag)
        self.setScene(self._scene)
        self.setTransformationAnchor(QtWidgets.QGraphicsView.AnchorViewCenter)
        self.setResizeAnchor(QtWidgets.QGraphicsView.AnchorViewCenter)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setRenderHint(QtGui.QPainter.Antialiasing)
        self.setMaximumHeight(60)
        self.setMinimumHeight(60)
        self.setBackgroundBrush(QtGui.QBrush(QtGui.QColor(30, 30, 30)))
        self.mousePressPose = QtCore.QPointF(0, 0)
        self.mousePos = QtCore.QPointF(0, 0)
        self._lastMousePos = QtCore.QPointF(0, 0)
        self.pressed_item = None
        self.itemSize = 6
        self.displayPoints = []

        for x in self._rawRamp.sortedItems():
            self.addItem(raw_item=x)
        self.update() 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:35,代码来源:QtSliders.py

示例5: asVariableGetter

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def asVariableGetter(node, painter, option, widget):
        painter.setPen(QtCore.Qt.NoPen)
        painter.setBrush(QtCore.Qt.darkGray)

        color = node.color
        if node.isSelected():
            color = color.lighter(150)

        linearGrad = QtGui.QRadialGradient(QtCore.QPointF(40, 40), 300)
        linearGrad.setColorAt(0, color)
        linearGrad.setColorAt(1, color.lighter(180))
        br = QtGui.QBrush(linearGrad)
        painter.setBrush(br)
        pen = QtGui.QPen(QtCore.Qt.black, 0.5)
        if option.state & QStyle.State_Selected:
            pen.setColor(editableStyleSheet().MainColor)
            pen.setStyle(node.optPenSelectedType)
        painter.setPen(pen)
        painter.drawRoundedRect(node.boundingRect(),
                                node.roundness, node.roundness)
        painter.setFont(node.nodeNameFont)
        painter.setPen(QtGui.QPen(QtCore.Qt.white, 0.5))
        textRect = node.boundingRect()
        textRect.setWidth(textRect.width() - 10)
        painter.drawText(textRect, QtCore.Qt.AlignCenter |
                         QtCore.Qt.AlignVCenter, node.var.name) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:28,代码来源:Painters.py

示例6: asRerouteNode

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def asRerouteNode(node, painter, option, widget):
        color = node.color
        color.setAlpha(255)
        # if node.isSelected():
        color = color.lighter(100)
        if node.isTemp:
            color = color.lighter(50)
            color.setAlpha(50)
        linearGrad = QtGui.QRadialGradient(QtCore.QPointF(40, 40), 300)
        linearGrad.setColorAt(0, color)
        linearGrad.setColorAt(1, color.lighter(180))
        br = QtGui.QBrush(linearGrad)
        painter.setBrush(br)

        pen = QtGui.QPen(QtCore.Qt.black, 0.75)
        width = pen.width()
        if option.state & QStyle.State_Selected:
            # pen.setColor(Colors.Yellow)
            pen.setColor(editableStyleSheet().MainColor)
            pen.setStyle(node.optPenSelectedType)
            pen.setWidth(width * 1.5)
        painter.setPen(pen)
        painter.drawEllipse(node.boundingRect().center(
        ), node.drawRect.width() / 2, node.drawRect.width() / 2)


# Determines how to paint a pin 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:29,代码来源:Painters.py

示例7: asGroupPin

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def asGroupPin(pin, painter, option, widget):
        painter.setPen(PinPainter._groupPen)
        painter.setBrush(QtGui.QBrush(Colors.AbsoluteBlack))
        # painter.setBrush(QtCore.Qt.NoBrush)
        if not pin.expanded:
            arrow = QtGui.QPolygonF([QtCore.QPointF(0.0, 0.0),
                                     QtCore.QPointF(
                                         pin.pinSize, pin.pinSize / 2.0),
                                     QtCore.QPointF(0, pin.pinSize)])
        else:
            arrow = QtGui.QPolygonF([QtCore.QPointF(pin.pinSize / 2, pin.pinSize),
                                     QtCore.QPointF(0, 0),
                                     QtCore.QPointF(pin.pinSize, 0)])
        painter.drawPolygon(arrow) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:16,代码来源:Painters.py

示例8: asArrayPin

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def asArrayPin(pin, painter, option, widget):
        lod = pin.owningNode().canvasRef().getCanvasLodValueFromCurrentScale()
        SWITCH_LOD = editableStyleSheet().PinSwitch[0]
        gridSize = 3
        cellW = pin.pinSize / gridSize
        cellH = pin.pinSize / gridSize
        pinCenter = pin.pinCenter()
        halfPinSize = pin.pinSize / 2

        painter.setBrush(QtGui.QBrush(pin.color()))
        painter.setPen(QtGui.QPen(QtCore.Qt.black, 0.2))
        for row in range(gridSize):
            for column in range(gridSize):
                x = row * cellW + pinCenter.x() - halfPinSize
                y = column * cellH + pinCenter.y() - halfPinSize
                painter.drawRect(x, y, cellW, cellH)

        if lod < SWITCH_LOD and not pin.bLabelHidden:
            frame = QtCore.QRectF(QtCore.QPointF(0, 0), pin.geometry().size())
            halfPinSize = pin.pinSize / 2
            painter.setFont(pin._font)
            textWidth = QtGui.QFontMetrics(
                painter.font()).width(pin.displayName())
            textHeight = QtGui.QFontMetrics(painter.font()).height()
            x = 1 + pin.pinSize + halfPinSize
            if pin.direction == PinDirection.Output:
                x = frame.width() - textWidth - pin.pinSize - 1
            yCenter = textHeight - textHeight / 3
            painter.setPen(PinPainter._valuePinNamePen)
            painter.drawText(x, yCenter, pin.name)

            if pin.hovered:
                painter.setPen(QtCore.Qt.NoPen)
                painter.setBrush(QtGui.QColor(128, 128, 128, 30))
                painter.drawRoundedRect(frame, 3, 3) 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:37,代码来源:Painters.py

示例9: asDictPin

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def asDictPin(pin, painter, option, widget):
        lod = pin.owningNode().canvasRef().getCanvasLodValueFromCurrentScale()
        SWITCH_LOD = editableStyleSheet().PinSwitch[0]
        cellW = pin.pinSize / 3
        cellH = pin.pinSize / 3
        pinCenter = pin.pinCenter()
        halfPinSize = pin.pinSize / 2

        painter.setBrush(QtGui.QBrush(pin.color()))
        keyPin = findPinClassByType(pin._rawPin._keyType)
        painter.setPen(QtGui.QPen(QtCore.Qt.black, 0.2))
        for row in range(3):
            x = pinCenter.x() - halfPinSize
            y = row * cellH + (halfPinSize / 2) + pin.pinCircleDrawOffset.y()
            painter.setBrush(QtGui.QBrush(pin.color()))
            painter.drawRect(x + cellW, y, cellW * 2, cellH)
            if keyPin:
                painter.setBrush(QtGui.QBrush(QtGui.QColor(*keyPin.color())))
            painter.drawRect(x, y, cellW, cellH)

        if lod < SWITCH_LOD and not pin.bLabelHidden:
            frame = QtCore.QRectF(QtCore.QPointF(0, 0), pin.geometry().size())
            halfPinSize = pin.pinSize / 2
            painter.setFont(pin._font)
            textWidth = QtGui.QFontMetrics(
                painter.font()).width(pin.displayName())
            textHeight = QtGui.QFontMetrics(painter.font()).height()
            x = 1 + pin.pinSize + halfPinSize
            if pin.direction == PinDirection.Output:
                x = frame.width() - textWidth - pin.pinSize - 1
            yCenter = textHeight - textHeight / 3
            painter.setPen(PinPainter._valuePinNamePen)
            painter.drawText(x, yCenter, pin.name)

            if pin.hovered:
                painter.setPen(QtCore.Qt.NoPen)
                painter.setBrush(QtGui.QColor(128, 128, 128, 30))
                painter.drawRoundedRect(frame, 3, 3)

# Determines how to paint a connection: 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:42,代码来源:Painters.py

示例10: __init__

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def __init__(self, parent, attribute, preset, index, dataType, maxConnections):
        """
        Initialize the class.

        :param parent: The parent item of the slot.
        :type  parent: QtWidgets.QGraphicsItem instance.

        :param attribute: The attribute associated to the slot.
        :type  attribute: String.

        :param index: int.
        :type  index: The index of the attribute in the node.

        :type  preset: str.
        :param preset: The name of graphical preset in the config file.

        :param dataType: The data type associated to the attribute.
        :type  dataType: Type.

        """
        super(SlotItem, self).__init__(parent)

        # Status.
        self.setAcceptHoverEvents(True)

        # Storage.
        self.slotType = None
        self.attribute = attribute
        self.preset = preset
        self.index = index
        self.dataType = dataType

        # Style.
        self.brush = QtGui.QBrush()
        self.brush.setStyle(QtCore.Qt.SolidPattern)

        self.pen = QtGui.QPen()
        self.pen.setStyle(QtCore.Qt.SolidLine)

        # Connections storage.
        self.connected_slots = list()
        self.newConnection = None
        self.connections = list()
        self.maxConnections = maxConnections 
开发者ID:LeGoffLoic,项目名称:Nodz,代码行数:46,代码来源:nodz_main.py

示例11: paint

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def paint(self, painter, option, widget=None):
        """Re-implement paint method

        """
        # Update level of detail
        self._lod = option.levelOfDetailFromTransform(painter.worldTransform())

        # Update brush
        palette = (self.scene().palette() if self.scene()
                   else option.palette)
        brush = palette.text()
        if option.state & QtWidgets.QStyle.State_Selected:
            brush = palette.highlight()
        elif option.state & QtWidgets.QStyle.State_MouseOver:
            color = brush.color().darker(250)
            brush.setColor(color)

        # Update unit width
        width = (1 / self._lod if self._outline * self._lod < 1
                 else self._outline)

        # Draw line
        painter.setPen(QtGui.QPen(brush, width))
        painter.drawLine(self._line)

        # Draw arrow if needed
        if self._arrow and self._lod > 0.15:
            # Construct arrow
            matrix = QtGui.QTransform()
            matrix.rotate(-self._line.angle())
            matrix.scale(width, width)

            if self._arrow & self.ARROW_STANDARD:
                poly = matrix.map(ARROW_STANDARD)
            elif self._arrow & self.ARROW_SLIM:
                poly = matrix.map(ARROW_SLIM)

            v = self._line.unitVector()
            v = (self._line.length() / 2) * QtCore.QPointF(v.x2() - v.x1(),
                                                           v.y2() - v.y1())
            poly.translate(self._line.x1(), self._line.y1())
            poly.translate(v.x(), v.y())

            painter.setPen(QtCore.Qt.NoPen)
            painter.setBrush(brush)
            painter.drawPolygon(poly)

        # Draw debug
        if DEBUG:
            painter.setBrush(QtGui.QBrush())
            painter.setPen(QtGui.QColor(255, 0, 0))
            painter.drawPath(self.shape())

            painter.setPen(QtGui.QColor(0, 255, 0))
            painter.drawRect(self.boundingRect())

        return 
开发者ID:dsideb,项目名称:nodegraph-pyqt,代码行数:59,代码来源:edge.py

示例12: paintEvent

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def paintEvent(self, event):
        painter = QtGui.QPainter()
        painter.begin(self)

        keyColor = QtGui.QColor.fromRgb(*findPinClassByType(self.parent().dataType).color())

        structure = self.parent()._rawVariable.structure
        if structure == StructureType.Single:
            painter.setRenderHint(QtGui.QPainter.Antialiasing)
            pen = QtGui.QPen()
            pen.setColor(QtGui.QColor(0, 0, 0, 0))
            painter.setPen(pen)
            rect = event.rect()
            rect.setHeight(10)
            rect.setWidth(15)
            rect.moveTop(3)
            painter.setBrush(keyColor)
            painter.drawRoundedRect(rect, 5, 5)

        if structure == StructureType.Array:
            gridSize = 3
            size = self.height()
            cellW = size / gridSize
            cellH = size / gridSize

            painter.setBrush(QtGui.QBrush(keyColor))
            painter.setPen(QtGui.QPen(QtCore.Qt.black, 0.2))
            for row in range(gridSize):
                for column in range(gridSize):
                    x = row * cellW
                    y = column * cellH
                    painter.drawRect(x, y, cellW, cellH)

        if structure == StructureType.Dict:
            dictObject = self.parent()._rawVariable.value

            keyColor = QtGui.QColor.fromRgb(*findPinClassByType(dictObject.keyType).color())
            valueColor = QtGui.QColor.fromRgb(*findPinClassByType(dictObject.valueType).color())

            gridSize = 3
            size = self.height()
            cellW = size / gridSize
            cellH = size / gridSize

            painter.setBrush(QtGui.QBrush(keyColor))
            painter.setPen(QtGui.QPen(QtCore.Qt.black, 0.2))
            for row in range(gridSize):
                painter.setBrush(keyColor)
                painter.drawRect(0, row * cellH, cellW, cellH)
                painter.setBrush(valueColor)
                painter.drawRect(cellW, row * cellH, cellW * 2, cellH)

        painter.end()


# Variable class 
开发者ID:wonderworks-software,项目名称:PyFlow,代码行数:58,代码来源:UIVariable.py

示例13: generateScheme

# 需要导入模块: from Qt import QtGui [as 别名]
# 或者: from Qt.QtGui import QBrush [as 别名]
def generateScheme(self, apply=True):
        """Generate color palette
        By default the generated palette is also applied to the whole application
        To override supply the apply=False argument
        """
        BASE_COLOR = self.baseColor
        HIGHLIGHT_COLOR = self.highlightColor
        BRIGHTNESS_SPREAD = self.spread

        if self.__lightness(BASE_COLOR) > 0.5:
            SPREAD = 100 / BRIGHTNESS_SPREAD
        else:
            SPREAD = 100 * BRIGHTNESS_SPREAD

        if self.__lightness(HIGHLIGHT_COLOR) > 0.6:
            HIGHLIGHTEDTEXT_COLOR = BASE_COLOR.darker(SPREAD * 2)
        else:
            HIGHLIGHTEDTEXT_COLOR = BASE_COLOR.lighter(SPREAD * 2)

        self.palette.setBrush(QPalette.Window, QBrush(BASE_COLOR))

        self.palette.setBrush(QPalette.WindowText, QBrush(BASE_COLOR.lighter(SPREAD * 2)))
        self.palette.setBrush(QPalette.Foreground, QBrush(BASE_COLOR.lighter(SPREAD)))
        self.palette.setBrush(QPalette.Base, QBrush(BASE_COLOR))
        self.palette.setBrush(QPalette.AlternateBase, QBrush(BASE_COLOR.darker(SPREAD)))
        self.palette.setBrush(QPalette.ToolTipBase, QBrush(BASE_COLOR))
        self.palette.setBrush(QPalette.ToolTipText, QBrush(BASE_COLOR.lighter(SPREAD)))
        self.palette.setBrush(QPalette.Text, QBrush(BASE_COLOR.lighter(SPREAD * 1.8)))
        self.palette.setBrush(QPalette.Button, QBrush(BASE_COLOR))
        self.palette.setBrush(QPalette.ButtonText, QBrush(BASE_COLOR.lighter(SPREAD * 1.2)))
        self.palette.setBrush(QPalette.BrightText, QBrush(QColor("#ffffff")))

        self.palette.setBrush(QPalette.Light, QBrush(BASE_COLOR.lighter(SPREAD)))
        self.palette.setBrush(QPalette.Midlight, QBrush(BASE_COLOR.lighter(SPREAD / 2)))
        self.palette.setBrush(QPalette.Dark, QBrush(BASE_COLOR.darker(SPREAD)))
        self.palette.setBrush(QPalette.Mid, QBrush(BASE_COLOR))
        self.palette.setBrush(QPalette.Shadow, QBrush(BASE_COLOR.darker(SPREAD * 2)))

        self.palette.setBrush(QPalette.Highlight, QBrush(HIGHLIGHT_COLOR))
        self.palette.setBrush(QPalette.HighlightedText, QBrush(HIGHLIGHTEDTEXT_COLOR))
        if apply:
            QApplication.setPalette(self.palette) 
开发者ID:cineuse,项目名称:CNCGToolKit,代码行数:44,代码来源:StrackColorScheme.py


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