Пример #1
0
 def paintEvent(self, event):
     QWidget.paintEvent(self, event)
     painter = QPainter(self)
     painter.setBrush(QBrush(QColor(Qt.black)))
     painter.setPen(QPen())
     painter.setOpacity(self.value)
     painter.drawRect(self.rect())
Пример #2
0
    def drawIcon(self, colorRamp):
        # input color ramp object: QgsVectorColorRampV2 object.
        # QgsVectorColorRampV2 is a virtual object, the real object name in
        # this case is QgsVectorGradientColorRampV2 object.
        mStops = colorRamp.stops()
        linearGradient = QLinearGradient(0.0, 50.0, 200.0, 50.0)
        for item in mStops:
            linearGradient.setColorAt(item.offset, item.color)
        linearGradient.setSpread(QGradient.PadSpread)

        svgName = os.path.join(os.path.dirname(__file__), self.text() + '.svg')
        pix = QSvgGenerator()
        pix.setFileName(svgName)
        pix.setSize(QSize(200, 100))
        painter = QPainter()
        painter.begin(pix)
        br = QBrush(linearGradient)
        painter.setBrush(br)
        painter.drawRect(QRect(0, 0, 200, 100))
        painter.end()

        pixmap = QPixmap(svgName)
        icon = QIcon(pixmap)
        self.svgName = svgName

        return icon
    def paintEvent(self, event):

        painter = QPainter()
        painter.begin(self)

        painter.setRenderHint(QPainter.Antialiasing)
        painter.setPen(QPen(Qt.NoPen))
        painter.setBrush(QBrush(self.palette().color(QPalette.Highlight)))


        num = 8

        painter.translate(self.width()/2, self.height()/2)
        painter.rotate(360.0/num * (self.counter % num))

        for i in range(num):
            s = 25 + i

            x =  50 * math.cos(2.0 * math.pi * i / num) - s/2.0
            y =  50 * math.sin(2.0 * math.pi * i / num) - s/2.0


            painter.drawEllipse(
                x,
                y,
                s, s)
        painter.end()
Пример #4
0
	def paintEvent( self, event ):
		"""
		Das automatisch ausgelöste paintEvent, das das Widget bei jeder Fensterveränderung neu zeichnet.
		"""

		if self.__maximum > 0:
			frameWidth = 1
			separatorWidth = 1

			# Damit der Rahmen nicht irgendwie abgeschnitten wird, muß das Quadrat entsprechend kleiner sein.
			squareSideLength = 10
			framePen = QPen( frameWidth )
			framePen.setColor( self.__colorFrame )

			squareSideLengthPlus = squareSideLength + 2 * frameWidth

			painter = QPainter( self )

			windowWidth = self.width() / min( self.__maximum, self.__columnMax )
			windowHeight = self.__maximum / self.__columnMax
			windowHeight = math.ceil( windowHeight )
			windowHeight = self.height() / windowHeight
			side = min( windowWidth, windowHeight )

			painter.setRenderHint( QPainter.Antialiasing )

			# Wenn das Widget disabled ist, muß ich den Alphakanal meiner Farben verändern.
			if ( not self.isEnabled() ):
				painter.setOpacity( .5 )

			#painter.translate( float( windowWidth ), float( windowHeight ) )

			painter.scale( side / squareSideLengthPlus, side / squareSideLengthPlus )
			painter.setPen( framePen )
			painter.setBrush( self.__colorEmpty )

			painter.save()

			squareColumnIter = 0
			squareLineIter = 0
			squareCount = 0
			for squareCount in range(self.__maximum):
				square = QRect(
					( squareSideLength + separatorWidth ) * squareColumnIter + frameWidth * ( squareColumnIter + 1 ),
					( squareSideLength + separatorWidth ) * squareLineIter + frameWidth * ( squareLineIter + 1 ), squareSideLength, squareSideLength
				)
				painter.drawRect( square )

				# Wir zeichnen die ausgekreuzten Quadrate
				if (self.__value > (self.__columnMax * squareLineIter + squareColumnIter)):
					painter.drawLine(square.bottomLeft(), square.topRight())
					painter.drawLine(square.topLeft(), square.bottomRight())

				squareColumnIter += 1

				if ( squareColumnIter >= self.__columnMax ):
					squareColumnIter = 0
					squareLineIter += 1

			painter.restore()
Пример #5
0
    def make_piece_from_path(o, piece_id, qpainter_path):
        # generate the mask, and call back to actually create the piec.
        path = qpainter_path
        path.closeSubpath()
        #determine the required size of the mask
        mask_rect = path.boundingRect().toAlignedRect()
        #create the mask
        mask = QImage(mask_rect.size(), QImage.Format_ARGB32_Premultiplied)
        # fully transparent color
        mask.fill(0x00000000)

        painter = QPainter(mask)
        painter.translate(-mask_rect.topLeft())
        #we explicitly use a pen stroke in order to let the pieces overlap a bit (which reduces rendering glitches at the edges where puzzle pieces touch)
        # 1.0 still leaves the slightest trace of a glitch. but making the stroke thicker makes the plugs appear non-matching even when they belong together.
        # 2016-06-18: changed to 0.5 -- bevel looks better
        painter.setPen(QPen(Qt.black, 0.5))
        if o.outline_only:
            painter.setBrush(Qt.NoBrush)
        else:
            painter.setBrush(Qt.SolidPattern)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.drawPath(path)
        painter.end()

        o.add_piece_func(piece_id=piece_id,
                         mask_image=mask,
                         offset=mask_rect.topLeft())
Пример #6
0
    def paintEvent(self, event):
    
        if not self.text().isEmpty():
        
            painter = QPainter()
            painter.begin(self)
            painter.setRenderHint(QPainter.Antialiasing)
            
            color = self.palette().color(QPalette.Highlight)
            color.setAlpha(127)
            painter.setBrush(QBrush(color))
            color = self.palette().color(QPalette.HighlightedText)
            color.setAlpha(127)
            painter.setPen(QPen(color))
            size = self.height() / 2.0

            left = self.width() - 4
            
            painter.drawRect(left - size, size * 0.5, size, size)
            painter.drawLine(left - size * 0.75, size * 0.75,
                             left - size * 0.25, size * 1.25)
            painter.drawLine(left - size * 0.25, size * 0.75,
                             left - size * 0.75, size * 1.25)
            painter.end()
        
        QLabel.paintEvent(self, event)
Пример #7
0
    def __init__(self, parent, delegate):
        QWidget.__init__(self, parent)
        self.delegate = delegate
        self.emitted = False
        self.ui = Ui_AskVerdict()
        self.ui.setupUi(self)
        # build verdict icons
        if not AskVerdict.icons_cache:
            for i in range(self.ui.comboVerdict.count()):
                text = str(self.ui.comboVerdict.itemText(i))
                color = VERDICT_TO_ROW_COLORS.get(text[0])
                pixmap = QPixmap(16, 16)
                pixmap.fill(Qt.transparent)
                if color:
                    painter = QPainter(pixmap)
                    painter.setPen(Qt.black)
                    painter.setBrush(color)
                    painter.drawEllipse(0, 0, 15, 15)
                    painter.end()
                AskVerdict.icons_cache[text] = QIcon(pixmap)
        # set verdict icons
        for i in range(self.ui.comboVerdict.count()):
            text = str(self.ui.comboVerdict.itemText(i))
            self.ui.comboVerdict.setItemIcon(i, AskVerdict.icons_cache[text])

        self.ui.evaluate.clicked.connect(self.on_evaluate_clicked)
Пример #8
0
    def setNameAndBrush(self, sigma, color=Qt.black):
        self.sigma = sigma
        self.setText(str(self.brushSize))
        font = QFont()
        font.setPointSize(10)
        font.setBold(True)
        self.setFont(font)
        self.setForeground(color)

        pixmap = QPixmap(self.pixmapSize)
        pixmap.fill(Qt.transparent)
        painter = QPainter()
        painter.begin(pixmap)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setPen(color)
        brush = QBrush(color)
        painter.setBrush(brush)
        painter.drawEllipse(
            QRect(
                self.pixmapSize.width() / 2 - self.brushSize / 2,
                self.pixmapSize.height() / 2 - self.brushSize / 2,
                self.brushSize,
                self.brushSize,
            )
        )
        painter.end()
        self.setIcon(QIcon(pixmap))
        self.setTextAlignment(Qt.AlignVCenter)
Пример #9
0
    def __init__(self, parent, delegate):
        QWidget.__init__(self, parent)
        self.delegate = delegate
        self.emitted = False
        self.ui = Ui_AskVerdict()
        self.ui.setupUi(self)
        # build verdict icons
        if not AskVerdict.icons_cache:
            for i in range(self.ui.comboVerdict.count()):
                text = str(self.ui.comboVerdict.itemText(i))
                color = VERDICT_TO_ROW_COLORS.get(text[0])
                pixmap = QPixmap(16, 16)
                pixmap.fill(Qt.transparent)
                if color:
                    painter = QPainter(pixmap)
                    painter.setPen(Qt.black)
                    painter.setBrush(color)
                    painter.drawEllipse(0, 0, 15, 15)
                    painter.end()
                AskVerdict.icons_cache[text] = QIcon(pixmap)
        # set verdict icons
        for i in range(self.ui.comboVerdict.count()):
            text = str(self.ui.comboVerdict.itemText(i))
            self.ui.comboVerdict.setItemIcon(i, AskVerdict.icons_cache[text])

        self.ui.evaluate.clicked.connect(self.on_evaluate_clicked)
Пример #10
0
    def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        if not self.showRegionMap:
            painter.drawPixmap(0, 0, self.scaledOwnershipMap)
        rect = self.imageRect()
        if self.isEnabled():
            if self.showRegionMap:
                painter.drawPixmap(0, 0, self.scaledRegionMap)
            else:
                if self.currentTerritory:
                    painter.drawPixmap(0, 0, self.coloredMask(self.currentTerritory, QColor(*self.game.clientPlayer.color)))
                #draw active animations
                for a in self.animations:
                    painter.save()
                    a.paint(painter)
                    painter.restore()
                painter.drawPixmap(0, 0, self.scaledTroopCountMap)
        else:
            painter.fillRect(rect, QColor(0, 0, 0, 200))
            painter.drawText(rect, Qt.AlignCenter, "Waiting for the game to start.")

        #remaining troops
        if self.game.yourTurn() and self.game.remainingTroops:
            troopText = "Remaining troops: %d" % self.game.remainingTroops
            troopRect = QRect(0, 0, painter.fontMetrics().width(troopText) + 8, painter.fontMetrics().height() + 8)
            troopRect.moveBottomLeft(rect.bottomLeft())
            painter.setPen(Qt.white)
            painter.setBrush(QColor(0, 0, 0, 200))
            painter.drawRect(troopRect)
            painter.drawText(troopRect, Qt.AlignCenter, troopText)

        painter.end()
Пример #11
0
    def __init__(self, parent, color, shape):
        super(Piece, self).__init__(parent)

        self.color = color
        self.shape = shape
        cells = [QRect(11*x, 11*y, 11, 11) for x,y in self.cellCoor[self.shape]]

        self.setFixedSize(QSize(100, 100))

        self.setCheckable(True)

        self.i = QImage(56, 56, QImage.Format_ARGB32)
        self.i.fill(0x000000FF)

        p = QPainter(self.i)
        p.setBrush(self.colors[self.color])
        p.setPen(QColor(255, 255, 255, 255))
        p.drawRects(cells)

        self.setIconSize(QSize(56, 56))
        self.setIcon(QIcon(QPixmap.fromImage(self.i)))

        self.fliped = False
        self.rotated = 0

        self.d = QImage(256, 256, QImage.Format_ARGB32)
        self.updateImage()
Пример #12
0
 def paintEvent(self, event):
     painter = QPainter(self)
     painter.setBrush(QBrush(Qt.white))
     painter.setPen(Qt.NoPen)
     painter.drawRect(0, 0, self.width() - 1, self.height() - 1)
     painter.end()
     QSvgWidget.paintEvent(self, event)
Пример #13
0
    def paintEvent(self, event):
        painter = QPainter(self)
        icon = self.icon_pressed if self.isDown() else self.icon
        if icon is not None:
            x = (self.width() - icon.width()) / 2
            y = (self.height() - icon.height()) / 2
            painter.drawPixmap(x, y, icon)
        else:
            width = self.width()
            height = self.height()

            padding = width / 5
            radius = width - 2 * padding

            palette = self.palette()

            # Mid is darker than Dark. Go figure... -Dan
            bg_color = palette.color(
                QPalette.Mid) if self.isDown() else palette.color(
                    QPalette.Dark)
            fg_color = palette.color(
                QPalette.Window)  # or QPalette.Base for white

            painter.setRenderHint(QPainter.Antialiasing, True)
            painter.setBrush(bg_color)
            painter.setPen(bg_color)
            painter.drawEllipse(padding, padding, radius, radius)

            padding = padding * 2
            painter.setPen(fg_color)
            painter.drawLine(padding, padding, width - padding,
                             height - padding)
            painter.drawLine(padding, height - padding, width - padding,
                             padding)
Пример #14
0
 def paintEvent(self, e):
     painter = QPainter(self)
     painter.setPen(self.color)
     painter.setBrush(Qt.NoBrush)
     rect = QRect(self.x,self.y,self.w,self.h)
     painter.drawRect(rect)
     QWidget.paintEvent(self, e)
Пример #15
0
    def paintEvent(self, paint_event):
        QFrame.paintEvent(self, paint_event)
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        w = self.width()
        h = self.height()

        if self.horizontal:
            self.min_marker = QRectF(w * self.min_value, 4, self.size,
                                     self.size)
            self.max_marker = QRectF(w * self.max_value - self.size - 1, 4,
                                     self.size, self.size)
        else:
            self.min_marker = QRectF(4, h - h * self.min_value - self.size - 1,
                                     self.size, self.size)
            self.max_marker = QRectF(4, h - h * self.max_value, self.size,
                                     self.size)

        pen = painter.pen()
        pen.setWidth(0)
        pen.setColor(QApplication.palette().background().color().dark())
        painter.setPen(pen)

        painter.setBrush(self.min_marker_brush)
        painter.drawPie(self.min_marker, self.tilt * 16, 180 * 16)

        painter.setBrush(self.max_marker_brush)
        painter.drawPie(self.max_marker, self.tilt * 16, -180 * 16)
Пример #16
0
 def updateFilledCircle(self, s):
     size = s * self.zoom
     pixmap = QPixmap(self.width(), self.height())
     pixmap.fill(Qt.transparent)
     #painter filled ellipse
     p = QPalette()
     painter = QPainter()
     painter.begin(pixmap)
     painter.setRenderHint(QPainter.Antialiasing)
     brush = QBrush(p.link().color())
     painter.setBrush(brush)
     painter.setOpacity(0.4)
     painter.drawEllipse(QRect(self.width()/2 - size/2, self.height()/2 - size/2, size, size))
     painter.end()
     #painter ellipse 2
     painter2 = QPainter()
     painter2.begin(pixmap)
     painter2.setRenderHint(QPainter.Antialiasing)
     pen2 = QPen(Qt.green)
     pen2.setWidth(1)
     painter2.setPen(pen2)
     painter2.drawEllipse(QRect(self.width()/2 - size/2, self.height()/2 - size/2, size, size))
     painter2.end()
     
     self.ellipseLabel.setPixmap(QPixmap(pixmap))
     self.lastSize = s
Пример #17
0
 def updateCircle(self, s):
     size = s * self.zoom
     pixmap = QPixmap(self.width(), self.height())
     pixmap.fill(Qt.transparent)
     #painter ellipse 1
     painter = QPainter()
     painter.begin(pixmap)
     painter.setRenderHint(QPainter.Antialiasing)
     pen = QPen(Qt.red)
     pen.setWidth(3)
     painter.setPen(pen)
     brush = QBrush(Qt.green)
     painter.setBrush(brush)
     painter.drawEllipse(QRect(self.width()/2 - size/2, self.height()/2 - size/2, size, size))
     painter.end()
     #painter ellipse 2
     painter2 = QPainter()
     painter2.begin(pixmap)
     painter2.setRenderHint(QPainter.Antialiasing)
     pen2 = QPen(Qt.green)
     pen2.setStyle(Qt.DotLine)
     pen2.setWidth(3)
     painter2.setPen(pen2)
     painter2.drawEllipse(QRect(self.width()/2 - size/2, self.height()/2 - size/2, size, size))
     painter2.end()
     
     self.ellipseLabel.setPixmap(QPixmap(pixmap))
     self.lastSize = s
Пример #18
0
 def paintEvent( self, event ):
     """
     Overloads the paint event for this menu to draw its title based on its \
     show title property.
     
     :param      event | <QPaintEvent>
     """
     super(XMenu, self).paintEvent(event)
     
     if ( self.showTitle() ):
         painter = QPainter()
         painter.begin(self)
         
         palette = self.palette()
         
         painter.setBrush(palette.color(palette.Button))
         painter.setPen(Qt.NoPen)
         painter.drawRect(1, 1, self.width() - 2, 22)
         
         painter.setBrush(Qt.NoBrush)
         painter.setPen(palette.color(palette.ButtonText))
         painter.drawText(1, 1, self.width() - 2, 22, 
                          Qt.AlignCenter, self.title())
         
         painter.end()
 def paintEvent(self, event):
     'Paint semi-transparent background, animated pattern, background text'
     QWidget.paintEvent(self, event)
     # make a painter
     p = QPainter(self)
     p.setRenderHint(QPainter.TextAntialiasing)
     p.setRenderHint(QPainter.HighQualityAntialiasing)
     # fill a rectangle with transparent painting
     p.fillRect(event.rect(), Qt.transparent)
     # animated random dots background pattern
     for i in range(4096):
         x = randint(9, self.size().width() - 9)
         y = randint(9, self.size().height() - 9)
         p.setPen(QPen(QColor(randint(200, 255), randint(200, 255), 255), 1))
         p.drawPoint(x, y)
     # set pen to use white color
     p.setPen(QPen(QColor(randint(9, 255), randint(9, 255), 255), 1))
     # Rotate painter 45 Degree
     p.rotate(35)
     # Set painter Font for text
     p.setFont(QFont('Ubuntu', 300))
     # draw the background text, with antialiasing
     p.drawText(99, 199, "Radio")
     # Rotate -45 the QPen back !
     p.rotate(-35)
     # set the pen to no pen
     p.setPen(Qt.NoPen)
     # Background Color
     p.setBrush(QColor(0, 0, 0))
     # Background Opacity
     p.setOpacity(0.75)
     # Background Rounded Borders
     p.drawRoundedRect(self.rect(), 50, 50)
     # finalize the painter
     p.end()
Пример #20
0
def decorate_welcome_icon(icon, background_color):
    """Return a `QIcon` with a circle shaped background.
    """
    welcome_icon = QIcon()
    sizes = [32, 48, 64, 80]
    background_color = NAMED_COLORS.get(background_color, background_color)
    background_color = QColor(background_color)
    grad = radial_gradient(background_color)
    for size in sizes:
        icon_pixmap = icon.pixmap(5 * size / 8, 5 * size / 8)
        icon_size = icon_pixmap.size()
        icon_rect = QRect(QPoint(0, 0), icon_size)

        pixmap = QPixmap(size, size)
        pixmap.fill(QColor(0, 0, 0, 0))
        p = QPainter(pixmap)
        p.setRenderHint(QPainter.Antialiasing, True)
        p.setBrush(QBrush(grad))
        p.setPen(Qt.NoPen)
        ellipse_rect = QRect(0, 0, size, size)
        p.drawEllipse(ellipse_rect)
        icon_rect.moveCenter(ellipse_rect.center())
        p.drawPixmap(icon_rect.topLeft(), icon_pixmap)
        p.end()

        welcome_icon.addPixmap(pixmap)

    return welcome_icon
Пример #21
0
 def paintEvent(self, event=None):
     painter = QPainter(self)
     painter.setRenderHint(QPainter.Antialiasing, True)
     xOffset = self.width() / 3
     yOffset = self.height() / 3
     for x in range(3):
         for y in range(3):
             cell = self.grid[x][y]
             rect = (QRectF(x * xOffset, y * yOffset, xOffset,
                            yOffset).adjusted(0.5, 0.5, -0.5, -0.5))
             color = None
             if cell == RED:
                 color = Qt.red
             elif cell == YELLOW:
                 color = Qt.yellow
             if color is not None:
                 painter.save()
                 painter.setPen(Qt.black)
                 painter.setBrush(color)
                 painter.drawEllipse(rect.adjusted(2, 2, -2, -2))
                 painter.restore()
             if [x, y] == self.selected:
                 painter.setPen(QPen(Qt.blue, 3))
             else:
                 painter.setPen(Qt.black)
             painter.drawRect(rect)
Пример #22
0
    def __init__(self, parent, row, col):
        super(Board,self).__init__(parent)

        self.x = -1
        self.y = -1
        self.piece = None
        self.row = row
        self.col = col

        self.cellwidth = 50
        self.linewidth = 1

        self.width = self.cellwidth*col + self.linewidth*(col+1)
        self.height = self.cellwidth*row + self.linewidth*(row+1)

        self.setFixedSize(self.width, self.height)

        self.board = QImage(self.width, self.height, QImage.Format_ARGB32)
        self.pieces = QImage(self.width, self.height, QImage.Format_ARGB32)

        p = QPainter(self.board)
        p.setBrush(QColor(255, 255, 255, 255))
        p.drawRect(QRect(0, 0, self.width-1, self.height-1))
        linelist_x = [QLine(x, 0, x, self.height-1) for x in range(0, self.width, self.cellwidth+1)]
        linelist_y = [QLine(0, y, self.width-1, y) for y in range(0, self.height, self.cellwidth+1)]
        p.drawLines(linelist_x + linelist_y)

        self.pieces.fill(0x000000FF)

        self.setMouseTracking(True)
Пример #23
0
    def paintEvent(self, event):
        """
        Overloads the paint event to draw rounded edges on this widget.
        
        :param      event | <QPaintEvent>
        """
        super(XRolloutItem, self).paintEvent(event)

        painter = QPainter()
        painter.begin(self)

        w = self.width() - 3
        h = self.height() - 3

        color = self.palette().color(QPalette.Midlight)
        color = color.darker(180)
        pen = QPen(color)
        pen.setWidthF(0.5)

        painter.setPen(pen)
        painter.setBrush(self.palette().color(QPalette.Midlight))
        painter.setRenderHint(QPainter.Antialiasing)
        painter.drawRoundedRect(1, 1, w, h, 10, 10)

        painter.end()
Пример #24
0
    def _drawIcon(self, color=Qt.black):
        self.setForeground(QBrush(color))

        if self.isRootNode:
            pixmap = QPixmap(20, 20)
            pixmap.fill(Qt.transparent)
            painter = QPainter()
            painter.begin(pixmap)
            pen = QPen(color)
            pen.setWidth(1)
            painter.setPen(pen)
            painter.setBrush(color)
            painter.setRenderHint(QPainter.Antialiasing)
            if not self.isExpanded:
                arrowRightPolygon = [
                    QPoint(6, 6), QPoint(6, 14),
                    QPoint(14, 10)
                ]
                painter.drawPolygon(QPolygon(arrowRightPolygon))
            else:
                arrowDownPolygon = [
                    QPoint(6, 6), QPoint(15, 6),
                    QPoint(10, 14)
                ]
                painter.drawPolygon(QPolygon(arrowDownPolygon))
            painter.end()
            self.setIcon(QIcon(pixmap))
Пример #25
0
    def paintEvent(self, event):
        if not self.displayedWhenStopped and not self.isAnimated():
            return

        width = min(self.width(), self.height())

        p = QPainter(self)
        p.setRenderHint(QPainter.Antialiasing)

        outerRadius = (width-1) * 0.5
        innerRadius = (width-1) * 0.5 * 0.38

        capsuleHeight = outerRadius - innerRadius
        capsuleWidth  = capsuleHeight * 0.23 if width > 32 else capsuleHeight * 0.35
        capsuleRadius = capsuleWidth / 2

        for i in range(12):
            color = QColor(self.color)
            color.setAlphaF(float(1.0 - float(i / 12.0)))
            p.setPen(Qt.NoPen)
            p.setBrush(color)
            p.save()
            p.translate(self.rect().center())
            p.rotate(self.angle - float(i * 30.0))
            p.drawRoundedRect(-capsuleWidth * 0.5,\
                              -(innerRadius + capsuleHeight),\
                              capsuleWidth,\
                              capsuleHeight,\
                              capsuleRadius,\
                              capsuleRadius)
            p.restore()
Пример #26
0
    def draw_filled_polygon(self, outline_pen_with=0):
        if not self.scale_polygon_colors == None:
            painter_filled_polygon = QPainter(self)
            painter_filled_polygon.setRenderHint(QPainter.Antialiasing)
            # Koordinatenursprung in die Mitte der Flaeche legen
            painter_filled_polygon.translate(self.width() / 2, self.height() / 2)

            painter_filled_polygon.setPen(Qt.NoPen)

            self.pen.setWidth(outline_pen_with)
            if outline_pen_with > 0:
                painter_filled_polygon.setPen(self.pen)

            colored_scale_polygon = self.create_polygon_pie(
                ((self.widget_diameter / 2) - (self.pen.width() / 2)) * self.gauge_color_outer_radius_factor,
                (((self.widget_diameter / 2) - (self.pen.width() / 2)) * self.gauge_color_inner_radius_factor),
                self.scale_angle_start_value, self.scale_angle_size)

            gauge_rect = QRect(QPoint(0, 0), QSize(self.widget_diameter / 2 - 1, self.widget_diameter - 1))
            grad = QConicalGradient(QPointF(0, 0), - self.scale_angle_size - self.scale_angle_start_value +
                                    self.angle_offset - 1)

            # todo definition scale color as array here
            for eachcolor in self.scale_polygon_colors:
                grad.setColorAt(eachcolor[0], eachcolor[1])
            # grad.setColorAt(.00, Qt.red)
            # grad.setColorAt(.1, Qt.yellow)
            # grad.setColorAt(.15, Qt.green)
            # grad.setColorAt(1, Qt.transparent)
            painter_filled_polygon.setBrush(grad)
            # self.brush = QBrush(QColor(255, 0, 255, 255))
            # painter_filled_polygon.setBrush(self.brush)
            painter_filled_polygon.drawPolygon(colored_scale_polygon)
Пример #27
0
    def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 127)))
        painter.setPen(QPen(Qt.NoPen))

        for i in xrange(6):
            x_pos = self.width() / 2 + 30 * \
                math.cos(2 * math.pi * i / 6.0) - 10
            y_pos = self.height() / 2 + 30 * \
                math.sin(2 * math.pi * i / 6.0) - 10
            if (self.counter / 5) % 6 == i:
                linear_gradient = QLinearGradient(
                    x_pos + 10, x_pos, y_pos + 10, y_pos)
                linear_gradient.setColorAt(0, QColor(135, 206, 250))
                linear_gradient.setColorAt(1, QColor(0, 0, 128))
                painter.setBrush(QBrush(linear_gradient))
            else:
                linear_gradient = QLinearGradient(
                    x_pos - 10, x_pos, y_pos + 10, y_pos)
                linear_gradient.setColorAt(0, QColor(105, 105, 105))
                linear_gradient.setColorAt(1, QColor(0, 0, 0))
                painter.setBrush(QBrush(linear_gradient))
            painter.drawEllipse(
                x_pos,
                y_pos,
                20, 20)

        painter.end()
Пример #28
0
    def updateFilledCircle(self, s):
        size = s * self.zoom
        pixmap = QPixmap(self.width(), self.height())
        pixmap.fill(Qt.transparent)
        #painter filled ellipse
        p = QPalette()
        painter = QPainter()
        painter.begin(pixmap)
        painter.setRenderHint(QPainter.Antialiasing)
        brush = QBrush(p.link().color())
        painter.setBrush(brush)
        painter.setOpacity(0.4)
        painter.drawEllipse(
            QRect(self.width() / 2 - size / 2,
                  self.height() / 2 - size / 2, size, size))
        painter.end()
        #painter ellipse 2
        painter2 = QPainter()
        painter2.begin(pixmap)
        painter2.setRenderHint(QPainter.Antialiasing)
        pen2 = QPen(Qt.green)
        pen2.setWidth(1)
        painter2.setPen(pen2)
        painter2.drawEllipse(
            QRect(self.width() / 2 - size / 2,
                  self.height() / 2 - size / 2, size, size))
        painter2.end()

        self.ellipseLabel.setPixmap(QPixmap(pixmap))
        self.lastSize = s
Пример #29
0
    def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.fillRect(event.rect(), QBrush(QColor(255, 255, 255, 127)))
        painter.setPen(QPen(Qt.NoPen))

        for i in range(6):
            x_pos = self.width() / 2 + 30 * \
                math.cos(2 * math.pi * i / 6.0) - 10
            y_pos = self.height() / 2 + 30 * \
                math.sin(2 * math.pi * i / 6.0) - 10
            if (self.counter / 5) % 6 == i:
                linear_gradient = QLinearGradient(x_pos + 10, x_pos,
                                                  y_pos + 10, y_pos)
                linear_gradient.setColorAt(0, QColor(135, 206, 250))
                linear_gradient.setColorAt(1, QColor(0, 0, 128))
                painter.setBrush(QBrush(linear_gradient))
            else:
                linear_gradient = QLinearGradient(x_pos - 10, x_pos,
                                                  y_pos + 10, y_pos)
                linear_gradient.setColorAt(0, QColor(105, 105, 105))
                linear_gradient.setColorAt(1, QColor(0, 0, 0))
                painter.setBrush(QBrush(linear_gradient))
            painter.drawEllipse(x_pos, y_pos, 20, 20)

        painter.end()
    def __init__(self, parent, delegate):
        QWidget.__init__(self, parent)
        self.delegate = delegate
        self.emitted = False
        self.ui = Ui_AskVerdict()
        self.ui.setupUi(self)
        # build verdict icons
        if not AskVerdict.icons_cache:
            for text in VERDICTS:
                color = VERDICT_TO_ROW_COLORS.get(text[0])
                pixmap = QPixmap(16, 16)
                pixmap.fill(Qt.transparent)
                if color:
                    painter = QPainter(pixmap)
                    painter.setPen(Qt.black)
                    painter.setBrush(color)
                    painter.drawEllipse(0, 0, 15, 15)
                    painter.end()
                AskVerdict.icons_cache[text] = QIcon(pixmap)

        # set combo verdict
        for text in ('other...', 'skip', 'retry'):
            self.ui.comboVerdict.addItem(AskVerdict.icons_cache[text], text)
        model = self.ui.comboVerdict.model()
        model.itemFromIndex(model.index(0, 0)).setSelectable(False)

        self.ui.comboVerdict.activated.connect(self.on_dropdown_item_activated)

        self.ui.goodVerdict.clicked.connect(self.on_good_bad_button_clicked)
        self.ui.goodVerdict.setIcon(AskVerdict.icons_cache["good"])

        self.ui.badVerdict.clicked.connect(self.on_good_bad_button_clicked)
        self.ui.badVerdict.setIcon(AskVerdict.icons_cache["bad"])
Пример #31
0
 def paintEvent(self, event):
     """
     Overloads the paint event to handle painting pointers for the popup \
     mode.
     
     :param      event | <QPaintEvent>
     """
     # use the base technique for the dialog mode
     if self.currentMode() == XPopupWidget.Mode.Dialog:
         super(XPopupWidget, self).paintEvent(event)
         return
     
     # setup the coloring options
     palette = self.palette()
     
     painter = QPainter()
     painter.begin(self)
     
     pen = QPen(palette.color(palette.Window).darker(130))
     pen.setWidthF(1.75)
     painter.setPen(pen)
     painter.setRenderHint(painter.Antialiasing)
     painter.setBrush(palette.color(palette.Window))
     painter.drawPath(self.borderPath())
     painter.end()
Пример #32
0
    def paintEvent(self, event):
        """ paint a circle for each bp """
        painter = QPainter(self)
        painter.fillRect(event.rect(), self.palette().color(QPalette.Window))
        painter.setPen(Qt.black)

        block = self.main_editor.firstVisibleBlock()
        block_num = block.blockNumber()
        top = int(self.main_editor.blockBoundingGeometry(block).translated(
            self.main_editor.contentOffset()).top())
        bottom = top + int(self.main_editor.blockBoundingRect(block).height())

        bounding_rect = self.main_editor.blockBoundingRect(block)

        bp_brush = QBrush(QColor(250, 0, 0, 128))

        while block.isValid() and top <= event.rect().bottom():
            if block.isVisible() and bottom >= event.rect().top():
                line = block_num + 1
                width = self.width() - self.MARGIN
                height = self.main_editor.fontMetrics().height()
                painter.setPen(Qt.black)
                painter.drawText(0, top, width, height, Qt.AlignRight, str(line))
                if line in self.breakpoints:
                    # paint break point
                    diameter = min(width, height) - 3
                    painter.setPen(Qt.NoPen)
                    painter.setBrush(bp_brush)
                    painter.drawEllipse((width - diameter) / 2, top + 1.5, diameter, diameter)

            block = block.next()
            bounding_rect = self.main_editor.blockBoundingRect(block)
            top = bottom
            bottom = top + int(bounding_rect.height())
            block_num += 1
Пример #33
0
    def paintEvent(self, event):
        """
        Overloads the paint event to handle painting pointers for the popup \
        mode.
        
        :param      event | <QPaintEvent>
        """
        # use the base technique for the dialog mode
        if self.currentMode() == XPopupWidget.Mode.Dialog:
            super(XPopupWidget, self).paintEvent(event)
            return

        # setup the coloring options
        palette = self.palette()

        painter = QPainter()
        painter.begin(self)

        pen = QPen(palette.color(palette.Window).darker(130))
        pen.setWidthF(1.75)
        painter.setPen(pen)
        painter.setRenderHint(painter.Antialiasing)
        painter.setBrush(palette.color(palette.Window))
        painter.drawPath(self.borderPath())
        painter.end()
Пример #34
0
    def paintEvent(self, e):
        Part.paintEvent(self, e)
        painter = QPainter(self)
        color = QColor(self._base)
        color.setAlpha(200)
        painter.setPen(color.dark(150))
        painter.setBrush(color.dark(115))
        painter.setRenderHint(QPainter.Antialiasing)

        painter.drawEllipse(11, 22, 10, 10)
        
        rect = QRectF(25, 17, 7, 20)
        painter.drawChord(rect, 270 * 16, 180 * 16)
        
        rect = QRectF(40, 11, 10, 30)
        painter.drawChord(rect, 270 * 16, 180 * 16)

        painter.drawEllipse(63, 14, 5, 5)
        painter.drawEllipse(63, 35, 5, 5)
        painter.drawEllipse(81, 14, 5, 5)
        painter.drawEllipse(81, 35, 5, 5)
        
        painter = None
        if self.data is None:
            text = None
        else:
            text = self.data.name        
        self.drawText(text)
Пример #35
0
 def paintEvent( self, event ):
     """
     Overloads the paint event to draw rounded edges on this widget.
     
     :param      event | <QPaintEvent>
     """
     super(XRolloutItem, self).paintEvent(event)
     
     painter = QPainter()
     painter.begin(self)
     
     w = self.width() - 3
     h = self.height() - 3
     
     color = self.palette().color(QPalette.Midlight)
     color = color.darker(180)
     pen = QPen(color)
     pen.setWidthF(0.5)
     
     painter.setPen(pen)
     painter.setBrush(self.palette().color(QPalette.Midlight))
     painter.setRenderHint(QPainter.Antialiasing)
     painter.drawRoundedRect(1, 1, w, h, 10, 10)
     
     painter.end()
Пример #36
0
    def paintEvent(self, event):
        painter = QPainter(self)
        icon = self.icon_pressed if self.isDown() else self.icon
        if icon is not None:
            x = (self.width() - icon.width()) / 2
            y = (self.height() - icon.height()) / 2
            painter.drawPixmap(x, y, icon)
        else:
            width = self.width()
            height = self.height()

            padding = width / 5
            radius = width - 2*padding

            palette = self.palette()

            # Mid is darker than Dark. Go figure... -Dan
            bg_color = palette.color(QPalette.Mid) if self.isDown() else palette.color(QPalette.Dark)
            fg_color = palette.color(QPalette.Window) # or QPalette.Base for white

            painter.setRenderHint(QPainter.Antialiasing, True)
            painter.setBrush(bg_color)
            painter.setPen(bg_color)
            painter.drawEllipse(padding, padding, radius, radius)

            padding = padding * 2
            painter.setPen(fg_color)
            painter.drawLine(padding, padding, width-padding, height-padding)
            painter.drawLine(padding, height-padding, width-padding, padding)
Пример #37
0
    def setNameAndBrush(self, sigma, color=Qt.black):
        self.sigma = sigma
        self.setText(
            decode_to_qstring("σ=%.1fpx" % self.sigma, "utf-8")
        )  # This file is encoded as utf-8, so this string should be decoded as such.
        total_window = 1 + 2 * int(self.sigma * self.window_size + 0.5)
        self.setToolTip("sigma = {:.1f} pixels, window diameter = {:.1f}".format(self.sigma, total_window))
        font = QFont()
        font.setPointSize(10)
        font.setBold(True)
        self.setFont(font)
        self.setForeground(color)

        pixmap = QPixmap(self.pixmapSize)
        pixmap.fill(Qt.transparent)
        painter = QPainter()
        painter.begin(pixmap)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setPen(color)
        brush = QBrush(color)
        painter.setBrush(brush)
        painter.drawEllipse(
            QRect(
                self.pixmapSize.width() / 2 - self.brushSize / 2,
                self.pixmapSize.height() / 2 - self.brushSize / 2,
                self.brushSize,
                self.brushSize,
            )
        )
        painter.end()
        self.setIcon(QIcon(pixmap))
        self.setTextAlignment(Qt.AlignVCenter)
Пример #38
0
def decorate_welcome_icon(icon, background_color):
    """Return a `QIcon` with a circle shaped background.
    """
    welcome_icon = QIcon()
    sizes = [32, 48, 64, 80]
    background_color = NAMED_COLORS.get(background_color, background_color)
    background_color = QColor(background_color)
    grad = radial_gradient(background_color)
    for size in sizes:
        icon_pixmap = icon.pixmap(5 * size / 8, 5 * size / 8)
        icon_size = icon_pixmap.size()
        icon_rect = QRect(QPoint(0, 0), icon_size)

        pixmap = QPixmap(size, size)
        pixmap.fill(QColor(0, 0, 0, 0))
        p = QPainter(pixmap)
        p.setRenderHint(QPainter.Antialiasing, True)
        p.setBrush(QBrush(grad))
        p.setPen(Qt.NoPen)
        ellipse_rect = QRect(0, 0, size, size)
        p.drawEllipse(ellipse_rect)
        icon_rect.moveCenter(ellipse_rect.center())
        p.drawPixmap(icon_rect.topLeft(), icon_pixmap)
        p.end()

        welcome_icon.addPixmap(pixmap)

    return welcome_icon
Пример #39
0
    def updateCircle(self, s):
        size = s * self.zoom
        pixmap = QPixmap(self.width(), self.height())
        pixmap.fill(Qt.transparent)
        #painter ellipse 1
        painter = QPainter()
        painter.begin(pixmap)
        painter.setRenderHint(QPainter.Antialiasing)
        pen = QPen(Qt.red)
        pen.setWidth(3)
        painter.setPen(pen)
        brush = QBrush(Qt.green)
        painter.setBrush(brush)
        painter.drawEllipse(
            QRect(self.width() / 2 - size / 2,
                  self.height() / 2 - size / 2, size, size))
        painter.end()
        #painter ellipse 2
        painter2 = QPainter()
        painter2.begin(pixmap)
        painter2.setRenderHint(QPainter.Antialiasing)
        pen2 = QPen(Qt.green)
        pen2.setStyle(Qt.DotLine)
        pen2.setWidth(3)
        painter2.setPen(pen2)
        painter2.drawEllipse(
            QRect(self.width() / 2 - size / 2,
                  self.height() / 2 - size / 2, size, size))
        painter2.end()

        self.ellipseLabel.setPixmap(QPixmap(pixmap))
        self.lastSize = s
Пример #40
0
 def paintEvent(self, e):
     painter = QPainter(self)
     painter.setPen(QColor(self._backgroundColor))
     painter.setBrush(QColor(self._backgroundColor))
     painter.drawRect(0, 0, self.width(), self.height())
     painter.end()
     QFrame.paintEvent(self, e)
Пример #41
0
def draw_image(name, q):
  image = QSvgGenerator()
  image.setSize(QSize(IMAGE_SIZE, IMAGE_SIZE))
  image.setFileName(name + ".svg")

  painter = QPainter()
  painter.begin(image)
  painter.setBrush(Qt.white)
  painter.setPen(Qt.NoPen)
  painter.drawEllipse(QPointF(IMAGE_SIZE/2, IMAGE_SIZE/2), IMAGE_SIZE/2, IMAGE_SIZE/2)
  painter.setBrush(QBrush())
  painter.setPen(QPen())
  
  draw_defect(painter, q)
  draw_circle(painter, q)
  
  pen = QPen()
  pen.setWidth(7)
  pen.setColor(Qt.red)
  painter.setPen(pen)
  
  painter.drawLine(IMAGE_SIZE/2 - ARROW_SIZE, IMAGE_SIZE/2, IMAGE_SIZE/2 + ARROW_SIZE, IMAGE_SIZE/2)
  painter.drawLine(IMAGE_SIZE/2 + ARROW_SIZE, IMAGE_SIZE/2, IMAGE_SIZE/2 + ARROW_SIZE - 30, IMAGE_SIZE/2 + 20)
  painter.drawLine(IMAGE_SIZE/2 + ARROW_SIZE, IMAGE_SIZE/2, IMAGE_SIZE/2 + ARROW_SIZE - 30, IMAGE_SIZE/2 - 20)
  
  font = painter.font()
  font.setPixelSize(40)
  font.setBold(True)
  painter.setFont(font)
  painter.drawText(QPointF(IMAGE_SIZE/2 + ARROW_SIZE - 30, IMAGE_SIZE/2 - 30), "E")
  
  painter.end()
Пример #42
0
 def paintEvent(self, event):
     painter = QPainter(self)
     painter.setBrush(QBrush(Qt.white))
     painter.setPen(Qt.NoPen)
     painter.drawRect(0, 0, self.width() - 1, self.height() - 1)
     painter.end()
     QSvgWidget.paintEvent(self, event)
Пример #43
0
    def paintEvent(self, paint_event):
        QFrame.paintEvent(self, paint_event)
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        w = self.width()
        h = self.height()

        if self.horizontal:
            self.min_marker = QRectF(w * self.min_value, 4, self.size, self.size)
            self.max_marker = QRectF(w * self.max_value - self.size - 1, 4, self.size, self.size)
        else:
            self.min_marker = QRectF(4, h - h * self.min_value - self.size - 1, self.size, self.size)
            self.max_marker = QRectF(4, h - h * self.max_value, self.size, self.size)

        pen = painter.pen()
        pen.setWidth(0)
        pen.setColor(QApplication.palette().background().color().dark())
        painter.setPen(pen)

        painter.setBrush(self.min_marker_brush)
        painter.drawPie(self.min_marker, self.tilt * 16, 180 * 16)

        painter.setBrush(self.max_marker_brush)
        painter.drawPie(self.max_marker, self.tilt * 16, -180 * 16)
Пример #44
0
 def paintEvent(self, event=None):
     painter = QPainter(self)
     painter.setRenderHint(QPainter.Antialiasing, True)
     xOffset = self.width() / 3
     yOffset = self.height() / 3
     for x in range(3):
         for y in range(3):
             cell = self.grid[x][y]
             rect = (QRectF(x * xOffset, y * yOffset,
                     xOffset, yOffset).adjusted(0.5, 0.5, -0.5, -0.5))
             color = None
             if cell == RED:
                 color = Qt.red
             elif cell == YELLOW:
                 color = Qt.yellow
             if color is not None:
                 painter.save()
                 painter.setPen(Qt.black)
                 painter.setBrush(color)
                 painter.drawEllipse(rect.adjusted(2, 2, -2, -2))
                 painter.restore()
             if [x, y] == self.selected:
                 painter.setPen(QPen(Qt.blue, 3))
             else:
                 painter.setPen(Qt.black)
             painter.drawRect(rect)
Пример #45
0
    def paintEvent(self, evt):
        # get the widget dimensions
        orig_width = self.width()
        orig_height = self.height()

        # fill perc % of the widget
        perc = 1
        width = int(orig_width * perc)
        height = int(orig_height * perc)

        # get the starting origin
        x_orig = int((orig_width - width) / 2)
        # we want to start at the bottom and draw up.
        y_orig = orig_height - int((orig_height - height) / 2)

        # a running x-position
        running_pos = x_orig

        # calculate to number of bars
        nbars = len(self.counts)

        # calculate the bar widths, this compilcation is
        # necessary because integer trunction severly cripples
        # the layout.
        remainder = width % nbars
        bar_width = [int(width / nbars)] * nbars
        for i in range(remainder):
            bar_width[i] += 1

        paint = QPainter()
        paint.begin(self)

        # determine the scaling factor
        max_val = np.max(self.counts)
        scale = 1. * height / max_val

        # determine if we have a colormap and drop into the appopriate
        # loop.
        if hasattr(self.colormap[0], '__iter__'):
            # assume we have a colormap
            for i in range(len(self.counts)):
                bar_height = self.counts[i]
                r, g, b = self.colormap[i]
                paint.setPen(QColor(r, g, b))
                paint.setBrush(QColor(r, g, b))
                paint.drawRect(running_pos, y_orig, bar_width[i], -bar_height)
                running_pos += bar_width[i]

        else:
            # we have a tuple
            r, g, b = self.colormap
            paint.setPen(QColor(r, g, b))
            paint.setBrush(QColor(r, g, b))
            for i in range(len(self.counts)):
                bar_height = self.counts[i] * scale
                paint.drawRect(running_pos, y_orig, bar_width[i], -bar_height)
                running_pos += bar_width[i]

        paint.end()
Пример #46
0
    def paintEvent(self, evt):
        # get the widget dimensions
        orig_width = self.width()
        orig_height = self.height()

        # fill perc % of the widget
        perc = 1
        width = int(orig_width * perc)
        height = int(orig_height * perc)

        # get the starting origin
        x_orig = int((orig_width - width) / 2)
        # we want to start at the bottom and draw up.
        y_orig = orig_height - int((orig_height - height) / 2)

        # a running x-position
        running_pos = x_orig

        # calculate to number of bars
        nbars = len(self.counts)

        # calculate the bar widths, this compilcation is
        # necessary because integer trunction severly cripples
        # the layout.
        remainder = width % nbars
        bar_width = [int(width / nbars)] * nbars
        for i in range(remainder):
            bar_width[i] += 1

        paint = QPainter()
        paint.begin(self)

        # determine the scaling factor
        max_val = np.max(self.counts)
        scale = 1.0 * height / max_val

        # determine if we have a colormap and drop into the appopriate
        # loop.
        if hasattr(self.colormap[0], "__iter__"):
            # assume we have a colormap
            for i in range(len(self.counts)):
                bar_height = self.counts[i]
                r, g, b = self.colormap[i]
                paint.setPen(QColor(r, g, b))
                paint.setBrush(QColor(r, g, b))
                paint.drawRect(running_pos, y_orig, bar_width[i], -bar_height)
                running_pos += bar_width[i]

        else:
            # we have a tuple
            r, g, b = self.colormap
            paint.setPen(QColor(r, g, b))
            paint.setBrush(QColor(r, g, b))
            for i in range(len(self.counts)):
                bar_height = self.counts[i] * scale
                paint.drawRect(running_pos, y_orig, bar_width[i], -bar_height)
                running_pos += bar_width[i]

        paint.end()
Пример #47
0
 def paintEvent(self, event):
     qp = QPainter(self)
     qp.setBrush(QBrush(self.color))
     qp.setPen(self.color)
     qp.drawRect(0, 0, 25, 25)
     qp.setBrush(Qt.NoBrush)
     qp.setPen(Qt.black)
     qp.drawRect(1, 1, 24, 24)
Пример #48
0
 def paintEvent(self, e: QPaintEvent):
     if e.isAccepted():
         p = QPainter(self)
         p.setPen(QColor(255, 255, 255))
         c = self.__node.type().color().darker()
         p.setBrush(QColor(c.red(), c.green(), c.blue(), 180))
         p.drawRoundedRect(1, 1, self.width() - 2, self.height() - 2, 5, 5)
         p.drawText(QRect(5, 5, self.width() - 10, self.height() - 10), Qt.AlignCenter, self.__name)
Пример #49
0
 def paint(self, p: QPainter):
     p.setBrush(self.type().color())
     p.drawEllipse(self.pos.x(), self.pos.y(), self.size, self.size)
     if len(self.lines) > 0:
         pen = p.pen()
         p.setBrush(self.type().color().darker())
         p.setPen(QColor(0, 0, 0, 0))
         p.drawEllipse(self.pos.x() + 2, self.pos.y() + 2, self.size - 4, self.size - 4)
         p.setPen(pen)
Пример #50
0
    def draw_ball(self):
        painter = QPainter(self.field)
        painter.translate(self.field.width() / 2, self.field.height() / 2)
        ball = self.config.ball

        if ball is not None:
            painter.setPen(QPen(QColor(255, 165, 0), 1))
            painter.setBrush(QColor(255, 165, 0))
            painter.drawEllipse(ball.x, ball.y, 4, 4)
Пример #51
0
 def paintEvent(self, event ):
     if  self.pendingMessageCount() == 0 :
         QWidget.paintEvent(self, event )
         return
     
     painter = QPainter( self )
     painter.setPen( Qt.NoPen )
     painter.setBrush( self.currentMessageBackground() )
     painter.drawRect( self.contentsRect() )
Пример #52
0
    def paintEvent(self, event):
        if not self.program:
            return
        # TODO: get rid of this call
        #self.ResizeCanvas()
        paint = QPainter(self)
        paint.setPen(self.colors["line"])
        paint.setFont(QtGui.QFont('Decorative', 10))
        for e in self.program.edges:
            if e != self.selectedEdge:
                self.drawArrow(
                    paint, self.vertices[e.source].x() + self.size / 2,
                    self.vertices[e.source].y() + self.size / 2,
                    self.vertices[e.destination].x() + self.size / 2,
                    self.vertices[e.destination].y() + self.size / 2)
            else:
                paint.setPen(self.colors["selected"])
                paint.setBrush(self.colors["selected"])
                self.drawArrow(
                    paint, self.vertices[e.source].x() + self.size / 2,
                    self.vertices[e.source].y() + self.size / 2,
                    self.vertices[e.destination].x() + self.size / 2,
                    self.vertices[e.destination].y() + self.size / 2)
                paint.setPen(self.colors["line"])
                paint.setBrush(self.colors["line"])

        paint.setPen(self.colors["vertex"])
        paint.setBrush(self.colors["vertex"])
        for task in self.vertices.values():
            if task == self.selectedVertex:
                paint.setPen(self.colors["selected"])
                paint.setBrush(self.colors["selected"])
                paint.drawEllipse(task)
                paint.setPen(self.colors["vertex"])
                paint.setBrush(self.colors["vertex"])
            else:
                paint.drawEllipse(task)

        paint.setPen(self.colors["text"])
        for v in self.vertices.keys():
            task = self.vertices[v]
            paint.drawText(task.center().x() - 2,
                           task.center().y() + 5, str(v.number))
            paint.drawText(task.topRight().x(),
                           task.topRight().y() + 5, str(v.name))

        paint.setPen(self.colors["line"])
        if self.edgeDraw:
            self.drawArrow(
                paint, self.curEdge[0].x() + self.size / 2,
                self.curEdge[0].y() + self.size / 2,
                QCursor.pos().x() -
                self.mapToGlobal(self.geometry().topLeft()).x(),
                QCursor.pos().y() -
                self.mapToGlobal(self.geometry().topLeft()).y())
        paint.end()
Пример #53
0
 def paintEvent(self, event):
     qp = QPainter()
     qp.begin(self)
     qp.setBrush(self.gradient)
     qp.setPen(Qt.transparent)
     qp.drawRect(0, 0, self.SIZE_X, self.SIZE_Y)
     qp.setBrush(QBrush(Qt.red))
     qp.setPen(Qt.red)
     qp.drawLine(0, self.reflectivity, self.SIZE_X, self.reflectivity)
     qp.end()
Пример #54
0
    def paintEvent(self, event):
        """ Reimplement the paint event

        """
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        palette = self.palette()
        painter.setPen(palette.dark().color())
        painter.setBrush(palette.window())
        painter.drawPath(self._path)
Пример #55
0
    def paintEvent(self, event ):
        if  self._queuedWidget.pendingMessageCount() == 0 :
            QToolBar.paintEvent( self, event )
            return

        brush = self._queuedWidget.currentMessageBackground()
        painter = QPainter( self )
        painter.setPen( brush.color().darker( 150 ) )
        painter.setBrush( brush )
        painter.drawRect( self.contentsRect().adjusted( 0, 0, -1, -1 ) )