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


Python QtGui.QBrush类代码示例

本文整理汇总了Python中PyQt5.QtGui.QBrush的典型用法代码示例。如果您正苦于以下问题:Python QBrush类的具体用法?Python QBrush怎么用?Python QBrush使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: RoundedPushButton1

class RoundedPushButton1(QPushButton):
    def __init__(self,parent, default_wide, default_high,text=''):
        QPushButton.__init__(self, parent)
        #self.resize(100,80)
        self.default_high=default_high
        self.default_wide=default_wide
        self.xrd=self.default_wide/10
        #self.yrd=self.default_high/10
        self.yrd=self.xrd
        #self.resize(self.default_wide,self.default_high)

        self.backgroundColor = QPalette().light().color()
        self.backgroundColor.setRgb(157,157,157) #(220,203,231)
        #self.backgroundColor.setAlpha(0)
        self.brush=QBrush(Qt.SolidPattern)

        self.textlabel=textQLabel(self,text)

    def paintEvent(self,event):
        #brush.setStyle(Qt.Dense1Pattern)
        self.brush.setColor(self.backgroundColor)
        self.painter=QPainter(self)
        self.painter.setRenderHint(QPainter.Antialiasing)
        
        self.painter.setPen(Qt.NoPen)
        self.painter.setBrush(self.brush)
        self.painter.drawRoundedRect(QRect(0,0,self.default_wide,self.default_high), self.xrd, self.yrd)
        #self.painter.drawPixmap(self.imgx, self.imgy, self.piximg)
        self.painter.end()
开发者ID:saknayo,项目名称:sspainter,代码行数:29,代码来源:_CustomWidgets.py

示例2: ModCrossButton

class ModCrossButton(QPushButton):
    def __init__(self,parent,path=None):
        QPushButton.__init__(self,parent)

        self.parent=parent


        #self.setAttribute(Qt.WA_TranslucentBackground, True)
        self.backgroundColor = QPalette().light().color()
        self.backgroundColor.setRgb(157,157,157) #(220,203,231)
        #self.backgroundColor.setAlpha(100)
        self.brush=QBrush(Qt.SolidPattern)


    def paintEvent(self,event):
        self.wide=self.width()
        self.high=self.height()
        self.xdis=self.wide/7
        self.ydis=self.xdis

        self.path=QPainterPath()
        self.path.setFillRule(Qt.OddEvenFill)

        self.path.moveTo(self.wide/2, self.high/2-self.xdis)
        self.path.arcTo(0,0, self.wide, self.high,0,360)
        #self.path.closeSubpath()

        self.path.moveTo(self.wide/2-self.xdis/2, self.ydis)
        self.path.lineTo(self.wide/2-self.xdis/2, self.high/2-self.xdis/2)
        self.path.lineTo(self.ydis, self.high/2-self.xdis/2)
        self.path.lineTo(self.ydis, self.high/2+self.xdis/2)
        self.path.lineTo(self.wide/2-self.xdis/2, self.high/2+self.xdis/2)
        self.path.lineTo(self.wide/2-self.xdis/2, self.high-self.ydis)
        self.path.lineTo(self.wide/2+self.xdis/2, self.high-self.ydis)
        self.path.lineTo(self.wide/2+self.xdis/2, self.high/2+self.xdis/2)
        self.path.lineTo(self.wide-self.ydis, self.high/2+self.xdis/2)
        self.path.lineTo(self.wide-self.ydis, self.high/2-self.xdis/2)
        self.path.lineTo(self.wide/2+self.xdis/2, self.high/2-self.xdis/2)
        self.path.lineTo(self.wide/2+self.xdis/2, self.ydis)
        self.path.closeSubpath()

        self.brush.setColor(self.backgroundColor)
        self.painter=QPainter(self)
        self.painter.setRenderHint(QPainter.Antialiasing)

        self.painter.setPen(Qt.NoPen)
        self.painter.setBrush(self.brush)
        self.painter.drawPath(self.path)
        self.painter.end()

    #def mousePressEvent(self,ev):
    #    self.parent.close()

    def enterEvent(self,ev):
        self.backgroundColor.setRgb(242,146,52) 
        self.update()
        
    def leaveEvent(self,ev):
        self.backgroundColor.setRgb(157,157,157)
        self.update()
开发者ID:saknayo,项目名称:sspainter,代码行数:60,代码来源:_CustomWidgets.py

示例3: QMarkablePicture

class QMarkablePicture(QLabel):
    def __init__(self, parent=None):
        QLabel.__init__(self, parent)
        self.initBrush()
        self.marks = []
        self.is_marks_count_limited = False
        self.marks_count_limit = 0

    def initBrush(self):
        self.brush = QBrush(Qt.SolidPattern)
        self.brush.setColor(QColor(constants.defaultBrushColor))

    def paintEvent(self, e):
        QLabel.paintEvent(self, e)
        painter = QPainter()
        painter.begin(self)
        painter.setBrush(self.brush)
        for mark in self.marks:
            painter.drawEllipse(mark, constants.ellipsWidth, constants.ellipsHeight)
        painter.end()

    def setBrushColor(self, color):
        self.brush.setColor(color)

    def drawMark(self, mark):
        if self.__isAbleDrawMark():
            self.marks.append(mark)
            self.update()

    def removeMark(self, mark):
        for painted_mark in self.marks:
            if self.__isApproximatelyEqual(mark, painted_mark, constants.epsilon):
                self.marks.remove(painted_mark)
                break
        self.update()

    def getMarks(self):
        return self.marks.copy()

    def setMarksCountLimit(self, limit):
        self.is_marks_count_limited = True
        self.marks_count_limit = limit

    def __isAbleDrawMark(self):
        limit_enabled_condition = self.is_marks_count_limited and (len(self.marks) < self.marks_count_limit)
        limit_disabled_condition = not self.is_marks_count_limited
        return limit_enabled_condition or limit_disabled_condition

    def __isApproximatelyEqual(self, firstMark, secondMark, epsilon):
        full_equality = firstMark == secondMark

        x_top_limit = (firstMark.x() + epsilon) >= secondMark.x()
        x_bottom_limit = (firstMark.x() - epsilon) <= secondMark.x()
        x_equality = x_top_limit and x_bottom_limit

        y_top_limit = (firstMark.y() + epsilon) >= secondMark.y()
        y_bottom_limit = (firstMark.y() - epsilon) <= secondMark.y()
        y_equality = y_top_limit and y_bottom_limit

        return full_equality or (x_equality and y_equality)
开发者ID:AlexeiBuzuma,项目名称:Coursework,代码行数:60,代码来源:custom_widgets.py

示例4: __init__

	def __init__(self, parent = None, message = None, itemType = "log"):
		QListWidgetItem.__init__(self)
		self.itemType = itemType

		if (itemType == "log"):
			self.setText("--- " + str(message))
		elif (itemType == "in"):
			self.setText("<<< " + str(message))
		elif (itemType == "out"):
			self.setText(">>> " + str(message))
		else:
			self.setText(str(message))

		font = QFont()
		font.setFamily("Monospace")
		if (itemType == "in") or (itemType == "out"):
			font.setBold(True)
			font.setWeight(75)
		else:
			font.setBold(False)
			font.setWeight(50)
		self.setFont(font)

		brush = QBrush(QColor(0, 0, 0))
		if (itemType == "in"):
			brush = QBrush(QColor(0, 0, 85))
		elif (itemType == "out"):
			brush = QBrush(QColor(0, 85, 0))
		brush.setStyle(Qt.NoBrush)
		self.setForeground(brush)
开发者ID:akkenoth,项目名称:BTSerial,代码行数:30,代码来源:LogItem.py

示例5: drawCircle

 def drawCircle(self, painter, centerX, centerY, color, size):
     pen = QPen(color, size)
     painter.setPen(pen)
     brush = QBrush(Qt.SolidPattern)
     brush.setColor(QColor(Qt.blue))
     painter.setBrush(brush)
     painter.drawEllipse(centerX, centerY, 5, 5)
开发者ID:aitormf,项目名称:TeachingRobotics,代码行数:7,代码来源:mapWidget.py

示例6: createArrow

    def createArrow(self):
        # add an arrow to destination line
        myLine = self.destinationLine.line()
        myLine.setLength(myLine.length() - TransitionGraphicsItem.ARROW_SIZE)
        rotatePoint = myLine.p2() - self.destinationLine.line().p2()

        rightPointX = rotatePoint.x() * math.cos(math.pi / 6) - rotatePoint.y() * math.sin(math.pi / 6)
        rightPointY = rotatePoint.x() * math.sin(math.pi / 6) + rotatePoint.y() * math.cos(math.pi / 6)
        rightPoint = QPointF(rightPointX + self.destinationLine.line().x2(),
                             rightPointY + self.destinationLine.line().y2())

        leftPointX = rotatePoint.x() * math.cos(-math.pi / 6) - rotatePoint.y() * math.sin(-math.pi / 6)
        leftPointY = rotatePoint.x() * math.sin(-math.pi / 6) + rotatePoint.y() * math.cos(-math.pi / 6)
        leftPoint = QPointF(leftPointX + self.destinationLine.line().x2(),
                            leftPointY + self.destinationLine.line().y2())

        polygon = QPolygonF()
        polygon << rightPoint << leftPoint << self.destinationLine.line().p2() << rightPoint

        if self.arrow == None:
            self.arrow = QGraphicsPolygonItem(polygon, self)
        else:
            self.arrow.setPolygon(polygon)

        brush = QBrush(Qt.SolidPattern)
        brush.setColor(Qt.black)
        self.arrow.setBrush(brush)
开发者ID:Diegojnb,项目名称:JdeRobot,代码行数:27,代码来源:guitransition.py

示例7: setStyle

 def setStyle(self, painter, fillColor, penColor, stroke):
     brush = QBrush()
     pen = QPen(penColor, stroke)
     brush.setColor(fillColor)
     brush.setStyle(Qt.SolidPattern)
     painter.setBrush(brush)
     painter.setPen(pen)
     painter.setRenderHint(QPainter.Antialiasing)
开发者ID:RoboticsURJC-students,项目名称:2016-tfg-vanessa-fernandez,代码行数:8,代码来源:referee.py

示例8: setRequired

 def setRequired(self, required):
     self.required = required
     brush = QBrush()
     if required:
         brush.setColor(QColor(255, 0, 0))
     else:
         brush.setColor(QColor(0, 0, 0))
     self.setForeground(0, brush)
开发者ID:NiyaziBalcii,项目名称:iso-work,代码行数:8,代码来源:packages.py

示例9: ModCloseButton

class ModCloseButton(QPushButton):
    def __init__(self,parent,wide,high,ppath=None):
        QPushButton.__init__(self,parent)

        self.parent=parent
        self.wide=wide
        self.high=high
        self.resize(self.wide,self.high)
        self.xdis=self.wide/10

        #self.setAttribute(Qt.WA_TranslucentBackground, True)
        self.backgroundColor = QPalette().light().color()
        self.backgroundColor.setRgb(157,157,157) #(220,203,231)
        #self.backgroundColor.setAlpha(100)
        self.brush=QBrush(Qt.SolidPattern)

        if ppath :
            self.path=ppath
        else :
            self.path=QPainterPath()

            self.path.moveTo(self.wide/2, self.high/2-self.xdis)
            self.path.arcTo(0,0, self.wide-2*self.xdis, self.high-2*self.xdis,45,90)
            self.path.closeSubpath()

            self.path.moveTo(self.wide/2-self.xdis, self.high/2)
            self.path.arcTo(0,0,self.wide-2*self.xdis,self.high-2*self.xdis,135,90)
            self.path.closeSubpath()

            self.path.moveTo(self.wide/2, self.high/2+self.xdis)
            self.path.arcTo(0,0,self.wide-2*self.xdis, self.high-2*self.xdis,225,90)
            self.path.closeSubpath()

            self.path.moveTo(self.wide/2+self.xdis, self.high/2)
            self.path.arcTo(0,0,self.wide-2*self.xdis, self.high-2*self.xdis,315,90)
            self.path.closeSubpath()

    def paintEvent(self,event):
        self.brush.setColor(self.backgroundColor)
        self.painter=QPainter(self)
        self.painter.setRenderHint(QPainter.Antialiasing)

        self.painter.setPen(Qt.NoPen)
        self.painter.setBrush(self.brush)
        self.painter.drawPath(self.path)
        self.painter.end()

    def mousePressEvent(self,ev):
        self.parent.close()

    def enterEvent(self,ev):
        self.backgroundColor.setRgb(234,39,13) 
        self.update()
        
    def leaveEvent(self,ev):
        self.backgroundColor.setRgb(157,157,157)
        self.update()
开发者ID:saknayo,项目名称:sspainter,代码行数:57,代码来源:_CustomWidgets.py

示例10: __set_brushAlpha

 def __set_brushAlpha(self, alpha: int):
     """
     Args:
         alpha: Description
     """
     brush = QBrush(self.item.brush())
     color = QColor(brush.color())
     color.setAlpha(alpha)
     self.item.setBrush(QBrush(color))
开发者ID:cadnano,项目名称:cadnano2.5,代码行数:9,代码来源:pathextras.py

示例11: valueChanged

    def valueChanged(self, property, value):
        if (not self.propertyToId.contains(property)):
            return

        if (not self.currentItem or self.currentItem.isNone()):
            return
        tp = type(value)
        id = self.propertyToId[property]
        if tp == float:
            if (id == "xpos"):
                self.currentItem.setX(value)
            elif (id == "ypos"):
                self.currentItem.setY(value)
            elif (id == "zpos"):
                self.currentItem.setZ(value)
        elif tp == str:
            if (id == "text"):
                if (self.currentItem.rtti() == RttiValues.Rtti_Text):
                    i = self.currentItem
                    i.setText(value)
        elif tp == QColor:
            if (id == "color"):
                if (self.currentItem.rtti() == RttiValues.Rtti_Text):
                    i = self.currentItem
                    i.setColor(value)
            elif (id == "brush"):
                if (self.currentItem.rtti() == RttiValues.Rtti_Rectangle or self.currentItem.rtti() == RttiValues.Rtti_Ellipse):
                    i = self.currentItem
                    b = QBrush(i.brush())
                    b.setColor(value)
                    i.setBrush(b)
            elif (id == "pen"):
                if (self.currentItem.rtti() == RttiValues.Rtti_Rectangle or self.currentItem.rtti() == RttiValues.Rtti_Line):
                    i = self.currentItem
                    p = QPen(i.pen())
                    p.setColor(value)
                    i.setPen(p)
        elif tp == QFont:
            if (id == "font"):
                if (self.currentItem.rtti() == RttiValues.Rtti_Text):
                    i = self.currentItem
                    i.setFont(value)
        elif tp == QPoint:
            if (self.currentItem.rtti() == RttiValues.Rtti_Line):
                i = self.currentItem
                if (id == "endpoint"):
                    i.setPoints(i.startPoint().x(), i.startPoint().y(), value.x(), value.y())
        elif tp == QSize:
            if (id == "size"):
                if (self.currentItem.rtti() == RttiValues.Rtti_Rectangle):
                    i = self.currentItem
                    i.setSize(value.width(), value.height())
                elif (self.currentItem.rtti() == RttiValues.Rtti_Ellipse):
                    i = self.currentItem
                    i.setSize(value.width(), value.height())
        self.canvas.update()
开发者ID:theall,项目名称:QtPropertyBrowserV2.6-for-pyqt5,代码行数:56,代码来源:canvas_typed.py

示例12: paintEvent

 def paintEvent(self, ev):
     pen = QPen()
     pen.setStyle(Qt.DotLine)
     pen.setWidth(2)
     pen.setColor(QColor(Qt.white))
     brush = QBrush()
     brush.setStyle(Qt.SolidPattern)
     brush.setColor(QColor(0, 0, 0))
     painter = QPainter(self)
     painter.setPen(pen)
     painter.setBrush(brush)
     painter.drawRect(ev.rect())
开发者ID:ozmartian,项目名称:ocr-translator,代码行数:12,代码来源:ocrtranslator.py

示例13: __set_brushAlpha

    def __set_brushAlpha(self, alpha):
        """Summary

        Args:
            alpha (TYPE): Description

        Returns:
            TYPE: Description
        """
        brush = QBrush(self.item.brush())
        color = QColor(brush.color())
        color.setAlpha(alpha)
        self.item.setBrush(QBrush(color))
开发者ID:hadim,项目名称:cadnano2.5,代码行数:13,代码来源:pathextras.py

示例14: __init__

    def __init__(self,  dblock: DBlock):
        super(DBlockTreeItem, self).__init__(dblock, dblock.name)
        self.dblock = dblock
        self.setSelectable(False)
        self.setEditable(False)

        self.tool_tip = "DBlock: " + dblock.name

        if isinstance(dblock, DEvent):
            brush = QBrush()
            brush.setColor(Qt.magenta)
            self.tool_tip = "DEvent: " + dblock.name
            self.setForeground(brush)
            self.setSelectable(True)
开发者ID:dani-l,项目名称:PaPI,代码行数:14,代码来源:item.py

示例15: WLLineLabel

class WLLineLabel(QPushButton):
    def __init__(self,parent):
        super(WLLineLabel,self).__init__(parent)
        self.setWindowFlags(Qt.FramelessWindowHint )
        self.linelength=1000
        self.lineheight=5
        self.resize(self.linelength, self.lineheight)
        self.move(100,100)
        self.stats=None
        #self.setStyleSheet("{background-color:transparent;border:none;color:transparent;}")

        self.backgroundColor = QPalette().light().color()
        self.backgroundColor.setRgb(157,157,157)#(220,203,231)
        #self.backgroundColor.setAlpha(255)
        self.brush=QBrush(Qt.SolidPattern)
    def paintEvent(self,event):
        self.brush.setColor(self.backgroundColor)
        self.painter=QPainter(self)
        self.painter.setRenderHint(QPainter.Antialiasing)

        self.painter.setPen(Qt.NoPen)
        self.painter.setBrush(self.brush)
        #print(self.geometry())
        self.painter.drawRect(0, 0, 1000, 5)
        self.painter.end()

    
    def statsReset(self):
        self.stats=None
        self.backgroundColor.setAlpha(255)
        self.redraw()
    def mousePressEvent(self,ev):
        if self.stats == 'selected' :
            self.stats = None
            self.backgroundColor.setAlpha(255)
        else:
            self.stats = 'selected'
            self.backgroundColor.setRgb(157,157,157)
        self.update()

    def enterEvent(self,ev):
        #print('enter')
        if self.stats != 'selected' :
            self.backgroundColor.setAlpha(0)
            self.update()
        
    def leaveEvent(self,ev):
        if self.stats != 'selected' :
            self.backgroundColor.setAlpha(255)
            self.update()
开发者ID:saknayo,项目名称:sspainter,代码行数:50,代码来源:_CustomWidgets.py


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