Exemplo n.º 1
0
 def draw_border(self):
     painter = QPainter(self)
     painter.setRenderHint(QPainter.Antialiasing)
     painter.translate(*self.center_p())
     painter.setPen(QPen(Qt.green, 3))
     x0, y0 = self.center_p()
     painter.drawRect(0 - x0, 0 - y0, self.width(), self.height())
Exemplo n.º 2
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)
Exemplo n.º 3
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)
Exemplo n.º 4
0
 def paintEvent(self, e):
     if self.active:
         painter = QPainter(self)
         pen = painter.pen()
         pen.setWidth(self.margin)
         pen.setColor(QColor('red').dark(150))
         painter.drawRect(0, 0, self.width(), self.height())
Exemplo n.º 5
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)
 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)
Exemplo n.º 7
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())
Exemplo n.º 8
0
    def paintEvent(self, event=None):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing, True)
        xOffset = self.width() / SIZE
        yOffset = self.height() / SIZE
        for x in range(SIZE):
            for y in range(SIZE):
                cell = self.grid[x][y]
                rect = (QRectF(x * xOffset, y * yOffset,
                        xOffset, yOffset).adjusted(0.5, 0.5, -0.5, -0.5))
		great_rect = QRectF(x * xOffset, y * yOffset,
                        xOffset, yOffset)
                
                if cell != BLANK:
                    painter.save()
                    painter.setPen(Qt.black)
		    font = QFont()
		    font.setPointSize(20)
		    painter.setFont(font)
		    painter.drawText(rect, Qt.AlignCenter, cell)
                    painter.restore()
                if [x, y] == self.selected:
                    painter.setPen(QPen(Qt.blue, SIZE))
                else:
                    painter.setPen(Qt.black)
                painter.drawRect(rect)
Exemplo n.º 9
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)
Exemplo n.º 10
0
    def paintEvent(self, event):
        p = QPainter(self)
        p.fillRect(event.rect(), Qt.white)
        start = self.m_offset / self.m_height
        y = start * self.m_height - self.m_offset
        if self.m_offset <= 0:
            start = 0
            y = -self.m_offset

        end = start + self.height() / self.m_height + 1
        if end > len(self.m_colorNames) - 1:
            end = len(self.m_colorNames) - 1
        for i in range(start, end):

            p.setBrush(Qt.NoBrush)
            p.setPen(Qt.black)
            if i == self.m_highlight:
                p.fillRect(0, y, self.width(), self.m_height, QColor(0, 64, 128))
                p.setPen(Qt.white)
            
            if i == self.m_selected:
                p.fillRect(0, y, self.width(), self.m_height, QColor(0, 128, 240))
                p.setPen(Qt.white)

            p.drawText(self.m_height + 2, y, self.width(), self.m_height, Qt.AlignVCenter, self.m_colorNames[i])

            p.setPen(Qt.NoPen)
            p.setBrush(QBrush(self.m_firstColor[i]))
            p.drawRect(1, y + 1, self.m_height - 2, self.m_height - 2)
            p.setBrush(QBrush(self.m_secondColor[i]))
            p.drawRect(5, y + 5, self.m_height - 11, self.m_height - 11)

            y += self.m_height
        
        p.end()
Exemplo n.º 11
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()
Exemplo n.º 12
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
Exemplo n.º 13
0
    def paintEvent(self, ev):
        color = self.palette().color(QPalette.Highlight)
        painter = QPainter(self)

        # Filled rectangle.
        painter.setClipRect(self.rect())
        color.setAlpha(50)
        painter.fillRect(self.rect().adjusted(2,2,-2,-2), color)

        # Thin rectangle outside.
        color.setAlpha(150)
        painter.setPen(color)
        painter.drawRect(self.rect().adjusted(0,0,-1,-1))

        # Pseudo-handles at the corners and sides
        color.setAlpha(100)
        pen = QPen(color)
        pen.setWidth(8)
        painter.setPen(pen)
        painter.setBackgroundMode(Qt.OpaqueMode)
        # Clip at 4 corners
        region = QRegion(QRect(0,0,20,20))
        region += QRect(self.rect().width()-20, 0, 20, 20)
        region += QRect(self.rect().width()-20, self.rect().height()-20, 20, 20)
        region += QRect(0, self.rect().height()-20, 20, 20)
        # Clip middles
        region += QRect(0, self.rect().height()/2-10, self.rect().width(), 20)
        region += QRect(self.rect().width()/2-10, 0, 20, self.rect().height())
        
        # Draw thicker rectangles, clipped at corners and sides.
        painter.setClipRegion(region)
        painter.drawRect(self.rect())
Exemplo n.º 14
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)
Exemplo n.º 15
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)
Exemplo n.º 16
0
 def paintEvent(self, event):
     if not self.tenant:
         return
     paint = QPainter(self)
     for e in self.tenant.edges:
             if e == self.selectedEdge:
                 paint.setPen(self.colors["selected"])
             else:
                 paint.setPen(self.colors["line"])
             self.drawArrow(paint, self.vertices[e.e1].x() + self.size / 2, self.vertices[e.e1].y() + self.size / 2,
                          self.vertices[e.e2].x() + self.size / 2, self.vertices[e.e2].y() + self.size / 2)
     for v in self.vertices.keys():
         pen = paint.pen()
         paint.setPen(Qt.red)
         if self.selectedVertex == self.vertices[v]:
             paint.drawRect(self.vertices[v])
         if isinstance(v, VM):
             paint.drawImage(self.vertices[v], self.computericon)
         elif isinstance(v, Storage):
             paint.drawImage(self.vertices[v], self.storageicon)
         elif isinstance(v, NetElement):
             if v.router:
                 paint.drawImage(self.vertices[v], self.routericon)
             else:
                 paint.drawImage(self.vertices[v], self.switchicon)
         elif isinstance(v, Vnf):
             paint.drawImage(self.vertices[v], self.serviceicon)
         elif isinstance(v, Domain):
             paint.drawImage(self.vertices[v], self.domainicon)
     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()
Exemplo n.º 17
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()
Exemplo n.º 18
0
 def drawBox(self):
     '''handle errors'''
     if not self.pixmap:
         self.showErrMsg('Please choose an image first!')
         return
         
     x, y, w, h = self.line_x.text(), self.line_y.text(), self.line_w.text(),\
         self.line_h.text()
     if not (x.isdigit() and y.isdigit() and w.isdigit() and h.isdigit()):
         self.showErrMsg('Please input integer!')
         return
     
     x, y, w, h = int(x), int(y), int(w), int(h)
     if not 0 <= x <= self.pixmap.width():
         self.showErrMsg('Value Error', 'x should be an integer between 0 and %d' 
             % self.pixmap.width())
     elif not 0 <= y <= self.pixmap.height():
         self.showErrMsg('Value Error', 'y should be an integer between 0 and %d'
             % self.pixmap.height())
     elif not 0 <= w <= (self.pixmap.width() - x):
         self.showErrMsg('Value Error', 'x + w should be an integer between 0 and %d'
             % self.pixmap.width())
     elif not 0 <= h <= (self.pixmap.height() - y):
         self.showErrMsg('Value Error', 'y + h should be an integer between 0 and %d'
             % self.pixmap.height())
     else:
         painter = QPainter()
         painter.begin(self.pixmap)
         pen = QPen(QtCore.Qt.red, 5, QtCore.Qt.SolidLine)
         painter.setPen(pen)
         painter.drawRect(x, y, w, h)
         painter.end()
         self.labelImage.setPixmap(self.pixmap)
Exemplo n.º 19
0
 def _paint_bg(self, p: QPainter):
     dpi = Info.dpi
     pen = self.pen()
     p.setRenderHint(QPainter.Antialiasing, True)
     p.setPen(pen)
     p.setBrush(self.bg())
     p.drawRoundedRect(OIBlock.padding * dpi, OIBlock.padding * dpi,
                       self.width() - 2 * OIBlock.padding * dpi,
                       self.height() - 2 * OIBlock.padding * dpi,
                       OIBlock.radius * dpi, OIBlock.radius * dpi)
     p.setBrush(self.title_bg())
     p.drawRoundedRect(OIBlock.padding * dpi, OIBlock.padding * dpi,
                       self.width() - 2 * OIBlock.padding * dpi,
                       .35 * dpi + OIBlock.padding * dpi,
                       OIBlock.radius * dpi, OIBlock.radius * dpi)
     p.setBrush(self.bg())
     p.setPen(QColor(0, 0, 0, 0))
     p.drawRect(0.01 * dpi + OIBlock.padding * dpi,
                0.35 * dpi + OIBlock.padding * dpi,
                self.width() - 0.02 * dpi - 2 * OIBlock.padding * dpi,
                0.10 * dpi)
     p.setPen(pen)
     if self._resizable:
         if self.__corner_path is None:
             self.__init_corner()
         p.setBrush(pen.brush())
         p.drawPath(
             self.__corner_path.translated(self.width(), self.height()))
	def drawROIBoxes(self, image):
		#print(self.frame_data)
		if not isinstance(self.frame_data, pd.DataFrame) or len(self.frame_data) == 0 \
		or not self.label_type in self.frame_data:
			return 
		 			
		self.img_h_ratio = image.height()/self.image_height;
		self.img_w_ratio = image.width()/self.image_width;

		painter = QPainter()
		painter.begin(image)
		for row_id, row_data in self.frame_data.iterrows():
			x = row_data['coord_x']*self.img_h_ratio
			y = row_data['coord_y']*self.img_w_ratio
			#check if the coordinates are nan
			if not (x == x) or  not (y == y): 
				continue

			x = int(x)
			y = int(y)
			c = self.wlabC[int(row_data[self.label_type])]
			
			painter.setPen(c)
			painter.setFont(QFont('Decorative', 10))
			
			painter.drawText(x, y, str(int(row_data[self.worm_index_type])))

			bb = row_data['roi_size']*self.img_w_ratio
			painter.drawRect(x-bb/2, y-bb/2, bb, bb);
		painter.end()
Exemplo n.º 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)
Exemplo n.º 22
0
    def paintEvent(self, event):
        super(DetailedProgress, self).paintEvent(event)
        if not self._current_progress:
            return

        painter = QPainter(self)
        width = self.width()
        height = self.height()
        aspect_ratio = float(width)/height
        nr_realizations = len(self._current_progress)
        fm_size = len(self._current_progress[0][1])
        self.grid_height = math.ceil(math.sqrt(nr_realizations / aspect_ratio))
        self.grid_width = math.ceil(self.grid_height * aspect_ratio)
        sub_grid_size = math.ceil(math.sqrt(fm_size))
        cell_height = height / self.grid_height
        cell_width = width / self.grid_width

        foreground_image = QImage(self.grid_width*sub_grid_size, self.grid_height*sub_grid_size, QImage.Format_ARGB32)
        foreground_image.fill(QColor(0, 0, 0, 0))

        for index, (iens, progress) in enumerate(self._current_progress):
            y = int(iens / self.grid_width)
            x = int(iens - (y * self.grid_width))
            self.draw_window(x * sub_grid_size, y * sub_grid_size, progress, foreground_image)
        painter.drawImage(self.contentsRect(), foreground_image)

        for index, (iens, progress) in enumerate(self._current_progress):
            y = int(iens / self.grid_width)
            x = int(iens - (y * self.grid_width))
            if iens == self.selected_realization:
                painter.setPen(QColor(240, 240, 240))
            else:
                painter.setPen(QColor(80, 80, 80))
            painter.drawRect(x * cell_width, y * cell_height, cell_width-1, cell_height-1)
            painter.drawText(x * cell_width + cell_width / 2, y * cell_height + cell_height / 2, str(iens))
Exemplo n.º 23
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 drawROIBoxes(self, image):
        #print(self.frame_data)
        if not isinstance(self.frame_data, pd.DataFrame) or len(self.frame_data) == 0 \
        or not self.label_type in self.frame_data:
            return

        self.img_h_ratio = image.height() / self.image_height
        self.img_w_ratio = image.width() / self.image_width

        painter = QPainter()
        painter.begin(image)
        for row_id, row_data in self.frame_data.iterrows():
            x = row_data['coord_x'] * self.img_h_ratio
            y = row_data['coord_y'] * self.img_w_ratio
            #check if the coordinates are nan
            if not (x == x) or not (y == y):
                continue

            x = int(x)
            y = int(y)
            c = self.wlabC[int(row_data[self.label_type])]

            painter.setPen(c)
            painter.setFont(QFont('Decorative', 10))

            painter.drawText(x, y, str(int(row_data[self.worm_index_type])))

            bb = row_data['roi_size'] * self.img_w_ratio
            painter.drawRect(x - bb / 2, y - bb / 2, bb, bb)
        painter.end()
Exemplo n.º 25
0
    def paintEvent(self, event=None):
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing, True)
        xOffset = self.width() / SIZE
        yOffset = self.height() / SIZE
        for x in range(SIZE):
            for y in range(SIZE):
                cell = self.grid[x][y]
                rect = (QRectF(x * xOffset, y * yOffset, xOffset,
                               yOffset).adjusted(0.5, 0.5, -0.5, -0.5))
                great_rect = QRectF(x * xOffset, y * yOffset, xOffset, yOffset)

                if cell != BLANK:
                    painter.save()
                    painter.setPen(Qt.black)
                    font = QFont()
                    font.setPointSize(20)
                    painter.setFont(font)
                    painter.drawText(rect, Qt.AlignCenter, cell)
                    painter.restore()
                if [x, y] == self.selected:
                    painter.setPen(QPen(Qt.blue, SIZE))
                else:
                    painter.setPen(Qt.black)
                painter.drawRect(rect)
Exemplo n.º 26
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()
Exemplo n.º 27
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()
Exemplo n.º 28
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)
Exemplo n.º 29
0
	def __setProgressPixmapInactive(self, pixmap):
		alpha = pixmap.alphaChannel()
		painter = QPainter()
		painter.begin(alpha)
		painter.setBrush(QBrush(QColor(0, 0, 0, 196)))
		painter.drawRect(pixmap.rect())
		painter.end()
		pixmap.setAlphaChannel(alpha)
Exemplo n.º 30
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)
Exemplo n.º 31
0
    def paintEvent(self,event):
        titleHeight = 40
        bottomHeight = 50
        
        #画标题背景
        painter = QPainter(self)
        painter.save()
        linearGradient = QLinearGradient(0, 0,0,titleHeight)
        linearGradient.setColorAt(0, QColor(60,150,255))
        linearGradient.setColorAt(0.1, QColor(6,88,200)) 
        linearGradient.setColorAt(1, QColor(80,150,255))
        painter.setBrush(QBrush(linearGradient))
        contenRect = QRect(0, 0, self.width(), titleHeight)
        painter.fillRect(contenRect, QBrush(linearGradient))
        painter.restore()
        
        #画标题内容
        painter.save()
        painter.setPen(QPen(QColor(255, 255, 255),1))
        font = painter.font()
        font.setPointSize(12)
        painter.setFont(font)
        painter.drawText(QPoint(10,25), self.title)
        painter.restore()
        
        #画中间白色背景
        painter.save()
        painter.setPen(QPen(QColor(255, 255, 255),1))
        brush = QBrush(QColor(242,242,242))
        painter.setBrush(brush)
        contenRect = QRect(0, titleHeight, self.width()-1, self.height() - titleHeight - bottomHeight)
#         painter.fillRect(contenRect, brush)
        painter.drawRect(contenRect)
        painter.restore()
        
        #画提示信息内容
        painter.save()
        painter.setPen(QPen(QColor(1, 1, 1),1))
        font = painter.font()
        font.setPointSize(15)
        painter.setFont(font)
        fm = QFontMetrics(font)
        infoWidth = fm.width(self.hintInfo)
        painter.drawText(QPoint((self.width() - infoWidth - 10)/2, 150), self.hintInfo)
        painter.restore()
        
        #画底层背景
        painter.save()
        brush = QBrush(QColor(219,234,255))
        painter.setBrush(brush)
        contenRect = QRect(0, self.height() - bottomHeight, self.width(), bottomHeight)
        painter.fillRect(contenRect, brush)
        painter.restore()
        
        
        
        
        
Exemplo n.º 32
0
def prepare_pixmap(image, c):
    pixmap = QPixmap.fromImage(image)
    painter = QPainter()
    painter.begin(pixmap)
    painter.drawRect(QRect(c.sub_image_anchor_px, c.sub_image_anchor_px,
                           c.sub_image_pxs, c.sub_image_pxs))  # draw center square
    painter.drawRect(QRect(0, 0, c.display_image_edge_pxs, c.display_image_edge_pxs))  # draw border
    painter.end()
    return pixmap
Exemplo n.º 33
0
    def paintEvent(self, event):
        super(DetailedProgress, self).paintEvent(event)
        if not self._current_progress:
            return

        painter = QPainter(self)
        width = self.width()
        height = self.height()
        aspect_ratio = float(width) / height
        nr_realizations = max([iens
                               for iens, _, _ in self._current_progress]) + 1
        fm_size = max(
            [len(progress) for _, progress, _ in self._current_progress])
        self.grid_height = math.ceil(math.sqrt(nr_realizations / aspect_ratio))
        self.grid_width = math.ceil(self.grid_height * aspect_ratio)
        sub_grid_size = math.ceil(math.sqrt(fm_size))
        cell_height = height / self.grid_height
        cell_width = width / self.grid_width

        foreground_image = QImage(self.grid_width * sub_grid_size,
                                  self.grid_height * sub_grid_size,
                                  QImage.Format_ARGB32)
        foreground_image.fill(QColor(0, 0, 0, 0))

        for index, (iens, progress, _) in enumerate(self._current_progress):
            y = int(iens / self.grid_width)
            x = int(iens - (y * self.grid_width))
            self.draw_window(x * sub_grid_size, y * sub_grid_size, progress,
                             foreground_image)
        painter.drawImage(self.contentsRect(), foreground_image)

        for index, (iens, progress,
                    state) in enumerate(self._current_progress):
            y = int(iens / self.grid_width)
            x = int(iens - (y * self.grid_width))

            painter.setPen(QColor(80, 80, 80))
            painter.drawText(x * cell_width, y * cell_height, cell_width,
                             cell_height, Qt.AlignHCenter | Qt.AlignVCenter,
                             str(iens))

            if iens == self.selected_realization:
                pen = QPen(QColor(240, 240, 240))
            elif (self.has_realization_failed(progress)):
                pen = QPen(QColor(*self.state_colors['Failure']))
            elif (state == JobStatusType.JOB_QUEUE_RUNNING):
                pen = QPen(QColor(*self.state_colors['Running']))
            else:
                pen = QPen(QColor(80, 80, 80))

            thickness = 4
            pen.setWidth(thickness)
            painter.setPen(pen)
            painter.drawRect((x * cell_width) + (thickness / 2),
                             (y * cell_height) + (thickness / 2),
                             cell_width - (thickness - 1),
                             cell_height - (thickness - 1))
Exemplo n.º 34
0
    def paintEvent(self, event):
        painter = QPainter(self)
        width = self.width()
        height = self.height()

        if self.scales_visible:
            curve_width = width - self.y_scale.total_width - self.curve_to_scale - self.curve_outer_border
            curve_height = height - self.y_scale_height_offset - self.x_scale.total_height - self.curve_to_scale
        else:
            curve_width = width - self.curve_outer_border - self.curve_outer_border
            curve_height = height - self.curve_outer_border - self.curve_outer_border

        if DEBUG:
            painter.fillRect(0, 0, width, height, Qt.green)

        # fill canvas
        if self.scales_visible:
            canvas_x = self.y_scale.total_width + self.curve_to_scale - self.curve_outer_border
            canvas_y = self.y_scale_height_offset - self.curve_outer_border
        else:
            canvas_x = 0
            canvas_y = 0

        canvas_width = self.curve_outer_border + curve_width + self.curve_outer_border
        canvas_height = self.curve_outer_border + curve_height + self.curve_outer_border

        painter.fillRect(canvas_x, canvas_y, canvas_width, canvas_height, self.canvas_color)

        # draw canvas border
        if self.curve_outer_border > 0:
            painter.setPen(QColor(190, 190, 190))
            painter.drawRect(
                canvas_x, canvas_y, canvas_width - 1, canvas_height - 1
            )  # -1 to accommodate the 1px width of the border
            painter.setPen(Qt.black)

        if DEBUG:
            painter.fillRect(
                canvas_x + self.curve_outer_border,
                canvas_y + self.curve_outer_border,
                curve_width,
                curve_height,
                Qt.cyan,
            )

        # draw scales
        if self.scales_visible:
            y_min_scale = self.y_scale.value_min
            y_max_scale = self.y_scale.value_max

            factor_x = float(curve_width) / self.history_length_x
            factor_y = float(curve_height - 1) / max(
                y_max_scale - y_min_scale, EPSILON
            )  # -1 to accommodate the 1px width of the curve

            self.draw_x_scale(painter, factor_x)
            self.draw_y_scale(painter, curve_height, factor_y)
Exemplo n.º 35
0
    def paintEvent(self, _):
        """
        :type _: QPaintEvent
        """

        painter = QPainter(self)
        painter.setBrush(QBrush(self.__rect_color))
        painter.setPen(QPen(self.__rect_color))
        painter.drawRect(self.__drag_and_drop_rect)
Exemplo n.º 36
0
 def paintEvent(self, e):
     painter = QPainter(self)
     painter.setBrush(self._base)
     if self.selected:
         painter.pen().setColor(QColor('yellow'))
     else:
         painter.pen().setColor(self._base.dark(150))
     painter.pen().setWidth(self.margin)
     painter.drawRect(0, 0, self.width(), self.height())
Exemplo n.º 37
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() )
Exemplo n.º 38
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()
Exemplo n.º 39
0
 def paintEvent(self, e):
     if self.active:
         painter = QPainter(self)
         pen = painter.pen()
         pen.setWidth(self.margin)
         pen.setColor(self.frame_color)
         color = QColor(self.frame_color)
         color.setAlpha(30)
         painter.setBrush(color)
         painter.drawRect(0, 0, self.width(), self.height())
Exemplo n.º 40
0
 def paintEvent(self, event):
     qp = QPainter()
     qp.begin(self)
     qp.setBrush(QBrush(self.color))
     qp.setPen(self.color)
     qp.drawRect(0, 0, 15, 15)
     qp.setBrush(Qt.NoBrush)
     qp.setPen(Qt.black)
     qp.drawRect(1, 1, 14, 14)
     qp.end()
Exemplo n.º 41
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()
Exemplo n.º 42
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 ) )
Exemplo n.º 43
0
 def paintEvent(self, event=None):
     font = QFont(self.font())
     font.setPointSize(font.pointSize() - 1)
     fm = QFontMetricsF(font)
     fracWidth = fm.width(FractionSlider.WSTRING)
     indent = fm.boundingRect("9").width() / 2.0
     if not X11:
         fracWidth *= 1.5
     span = self.width() - (FractionSlider.XMARGIN * 2)
     value = self.__numerator / float(self.__denominator)
     painter = QPainter(self)
     painter.setRenderHint(QPainter.Antialiasing)
     painter.setRenderHint(QPainter.TextAntialiasing)
     painter.setPen(self.palette().color(QPalette.Mid))
     painter.setBrush(self.palette().brush(
             QPalette.AlternateBase))
     painter.drawRect(self.rect())
     segColor = QColor(Qt.green).dark(120)
     segLineColor = segColor.dark()
     painter.setPen(segLineColor)
     painter.setBrush(segColor)
     painter.drawRect(FractionSlider.XMARGIN,
                      FractionSlider.YMARGIN, span, fm.height())
     textColor = self.palette().color(QPalette.Text)
     segWidth = span / self.__denominator
     segHeight = fm.height() * 2
     nRect = fm.boundingRect(FractionSlider.WSTRING)
     x = FractionSlider.XMARGIN
     yOffset = segHeight + fm.height()
     for i in range(self.__denominator + 1):
         painter.setPen(segLineColor)
         painter.drawLine(x, FractionSlider.YMARGIN, x, segHeight)
         painter.setPen(textColor)
         y = segHeight
         rect = QRectF(nRect)
         rect.moveCenter(QPointF(x, y + fm.height() / 2.0))
         painter.drawText(rect, Qt.AlignCenter,
                          QString.number(i))
         y = yOffset
         rect.moveCenter(QPointF(x, y + fm.height() / 2.0))
         painter.drawText(rect, Qt.AlignCenter,
                          QString.number(self.__denominator))
         painter.drawLine(QPointF(rect.left() + indent, y),
                          QPointF(rect.right() - indent, y))
         x += segWidth
     span = int(span)
     y = FractionSlider.YMARGIN - 0.5
     triangle = [QPointF(value * span, y),
                 QPointF((value * span) +
                         (2 * FractionSlider.XMARGIN), y),
                 QPointF((value * span) +
                         FractionSlider.XMARGIN, fm.height())]
     painter.setPen(Qt.yellow)
     painter.setBrush(Qt.darkYellow)
     painter.drawPolygon(QPolygonF(triangle))
Exemplo n.º 44
0
 def __add_black_border_(self, pixmap):
     """Add a black border around a pixmap
     
     @param pixmap: The pixmap
     @type pixmap: QPixmap
     """
     painter = QPainter()
     painter.begin(pixmap)
     painter.setPen(Qt.black);
     painter.drawRect(QRect(0, 0, pixmap.width() - 1, pixmap.height() - 1))
     painter.end()
Exemplo n.º 45
0
    def paintEvent(self, event):
        painter = QPainter(self)
        width = self.width()
        height = self.height()

        if self.scales_visible:
            curve_width = width - self.y_scale.total_width - self.curve_to_scale - self.curve_outer_border
            curve_height = height - self.y_scale_height_offset - self.x_scale.total_height - self.curve_to_scale
        else:
            curve_width = width - self.curve_outer_border - self.curve_outer_border
            curve_height = height - self.curve_outer_border - self.curve_outer_border

        if DEBUG:
            painter.fillRect(0, 0, width, height, Qt.green)

        # fill canvas
        if self.scales_visible:
            canvas_x = self.y_scale.total_width + self.curve_to_scale - self.curve_outer_border
            canvas_y = self.y_scale_height_offset - self.curve_outer_border
        else:
            canvas_x = 0
            canvas_y = 0

        canvas_width = self.curve_outer_border + curve_width + self.curve_outer_border
        canvas_height = self.curve_outer_border + curve_height + self.curve_outer_border

        painter.fillRect(canvas_x, canvas_y, canvas_width, canvas_height,
                         self.canvas_color)

        # draw canvas border
        if self.curve_outer_border > 0:
            painter.setPen(QColor(190, 190, 190))
            painter.drawRect(
                canvas_x, canvas_y, canvas_width - 1, canvas_height -
                1)  # -1 to accommodate the 1px width of the border
            painter.setPen(Qt.black)

        if DEBUG:
            painter.fillRect(canvas_x + self.curve_outer_border,
                             canvas_y + self.curve_outer_border, curve_width,
                             curve_height, Qt.cyan)

        # draw scales
        if self.scales_visible:
            y_min_scale = self.y_scale.value_min
            y_max_scale = self.y_scale.value_max

            factor_x = float(curve_width) / self.x_diff
            factor_y = float(curve_height - 1) / max(
                y_max_scale - y_min_scale,
                EPSILON)  # -1 to accommodate the 1px width of the curve

            self.draw_x_scale(painter, curve_width, factor_x)
            self.draw_y_scale(painter, curve_height, factor_y)
Exemplo n.º 46
0
 def drawPixmapForUnckecked(self):
     self.pixmapUnckecked = QPixmap(self.itemWidth, self.itemHeight)
     self.pixmapUnckecked.fill(Qt.transparent)
     painter = QPainter()
     painter.begin(self.pixmapUnckecked)
     painter.setRenderHint(QPainter.Antialiasing)
     pen = QPen()
     pen.setWidth(2)
     painter.setPen(pen)
     painter.drawRect(QRect(5,5,self.itemWidth-10, self.itemHeight-10))
     painter.end()
Exemplo n.º 47
0
    def paintEvent(self, paintevent):
        """Paints the box"""
        painter = QPainter(self)

        rect = self.contentsRect()
        rect.setWidth(rect.width() - 1)
        rect.setHeight(rect.height() - 1)
        painter.drawRect(rect)

        rect.setX(rect.x() + 1)
        rect.setY(rect.y() + 1)
        painter.fillRect(rect, self._getColor())
Exemplo n.º 48
0
 def updateColor(self):
     iconSize = self.iconSize()
     width = iconSize.width()
     height = iconSize.height()
     pixmap = QPixmap(iconSize)
     pixmap.fill(self._color)
     painter = QPainter()
     painter.begin(pixmap)
     painter.setPen(QPen(QColor("#777777")))
     painter.drawRect(QRect(0, 0, width - 1, height - 1))
     painter.end()
     self.setIcon(QIcon(pixmap))
Exemplo n.º 49
0
def palette_pixmap(colors, size):
    img = QPixmap(size)
    img.fill(Qt.transparent)

    painter = QPainter(img)
    grad = palette_gradient(colors)
    grad.setCoordinateMode(QLinearGradient.ObjectBoundingMode)
    painter.setPen(Qt.NoPen)
    painter.setBrush(QBrush(grad))
    painter.drawRect(0, 0, size.width(), size.height())
    painter.end()
    return img
Exemplo n.º 50
0
    def drawRectangle(self, x=0, y=0, w=0, h=0):
        """
        Draw a rectangle
        """
        self.mobileImageLabel.update()
        pixmap = self.mobileImageLabel.pixmap()
        if pixmap is not None:

            p = QPainter(pixmap)
            pen = QPen(Qt.red, 2, Qt.SolidLine)
            p.setPen(pen)
            p.drawRect(x, y, w, h)
            p.end()
Exemplo n.º 51
0
 def paintEvent(self, event):
     painter = QPainter(self)
     painter.fillRect(event.rect(), self.__background_color)
     # Draw markers
     self.__draw_markers(painter)
     # Draw slider
     if settings.DOCMAP_SLIDER and self.__scrollbar.isVisible():
         painter.setPen(Qt.NoPen)
         color = QColor(Qt.lightGray)
         color.setAlpha(50)
         painter.setBrush(QBrush(color))
         position1 = self.__get_position(self.__scrollbar.value())
         position2 = self.__get_position(self.__scrollbar.value() +
                                         self.__scrollbar.pageStep())
         painter.drawRect(0, position1, self.__width, position2 - position1)
Exemplo n.º 52
0
    def paintEvent(self, event):
        """
        Handles the drawing for this widget and its selection region.
        
        :param      event | <QPaintEvent>
        """
        pen = QPen(Qt.DashLine)
        pen.setColor(QColor('red'))
        painter = QPainter(self)
        painter.setPen(pen)
        clr = QColor('black')
        clr.setAlpha(100)
        painter.setBrush(clr)

        painter.drawRect(self._region)
Exemplo n.º 53
0
def grab_svg(scene):
    """
    Return a SVG rendering of the scene contents.

    Parameters
    ----------
    scene : :class:`CanvasScene`

    """
    from PyQt4.QtSvg import QSvgGenerator
    svg_buffer = QBuffer()
    gen = QSvgGenerator()
    gen.setOutputDevice(svg_buffer)

    items_rect = scene.itemsBoundingRect().adjusted(-10, -10, 10, 10)

    if items_rect.isNull():
        items_rect = QRectF(0, 0, 10, 10)

    width, height = items_rect.width(), items_rect.height()
    rect_ratio = float(width) / height

    # Keep a fixed aspect ratio.
    aspect_ratio = 1.618
    if rect_ratio > aspect_ratio:
        height = int(height * rect_ratio / aspect_ratio)
    else:
        width = int(width * aspect_ratio / rect_ratio)

    target_rect = QRectF(0, 0, width, height)
    source_rect = QRectF(0, 0, width, height)
    source_rect.moveCenter(items_rect.center())

    gen.setSize(target_rect.size().toSize())
    gen.setViewBox(target_rect)

    painter = QPainter(gen)

    # Draw background.
    painter.setBrush(QBrush(Qt.white))
    painter.drawRect(target_rect)

    # Render the scene
    scene.render(painter, target_rect, source_rect)
    painter.end()

    buffer_str = str(svg_buffer.buffer())
    return unicode(buffer_str.decode("utf-8"))
Exemplo n.º 54
0
 def drawPixmapForPartiallyChecked(self):
     self.pixmapPartiallyChecked = QPixmap(self.itemWidth, self.itemHeight)
     self.pixmapPartiallyChecked.fill(Qt.transparent)
     painter = QPainter()
     painter.begin(self.pixmapPartiallyChecked)
     painter.setRenderHint(QPainter.Antialiasing)
     pen = QPen()
     pen.setWidth(2)
     painter.setPen(pen)
     painter.drawRect(QRect(5,5,self.itemWidth-10, self.itemHeight-10))
     pen.setWidth(4)
     pen.setColor(QColor(139,137,137))
     painter.setPen(pen)
     painter.drawLine(self.itemWidth/2-5, self.itemHeight/2, self.itemWidth/2, self.itemHeight-9)
     painter.drawLine(self.itemWidth/2, self.itemHeight-9, self.itemWidth/2+10, 2)
     painter.end()
Exemplo n.º 55
0
 def _paint_bg(self, p: QPainter):
     pen = Block.selected_pen if self.__selected else Block.border_pen
     p.setRenderHint(QPainter.Antialiasing, True)
     p.setPen(pen)
     p.setBrush(self.bg())
     p.drawRoundedRect(Block.padding, Block.padding, self.width() - 2 * Block.padding,
                       self.height() - 2 * Block.padding, 8, 8)
     p.setBrush(self.title_bg())
     p.drawRoundedRect(Block.padding, Block.padding, self.width() - 2 * Block.padding, 35 + Block.padding, 8, 8)
     p.setBrush(self.bg())
     p.setPen(QColor(0, 0, 0, 0))
     p.drawRect(1 + Block.padding, 35 + Block.padding, self.width() - 2 - 2 * Block.padding, 10)
     p.setPen(pen)
     if self._resizable:
         p.setBrush(pen.brush())
         p.drawPath(self.__corner_path.translated(self.width(), self.height()))