def paintEvent(self, event):
        crect = self.rect()
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        painter.setBrush(QBrush(Qt.white))
        painter.setPen(QPen(Qt.lightGray, 1.2))
        painter.drawRoundedRect(
            QRectF(crect).adjusted(2, 2, -2, -2), 2, 2, Qt.AbsoluteSize)

        if self._selected:
            painter.setPen(QPen(QBrush(Qt.red), 2))
        if self._highlighted:
            painter.setBrush(QBrush(Qt.gray, Qt.FDiagPattern))
        else:
            painter.setBrush(Qt.NoBrush)

        painter.drawRoundedRect(
            QRectF(crect).adjusted(2, 2, -2, -2), 2, 2, Qt.AbsoluteSize)

        defsize = self.renderer().defaultSize()
        margin = 5

        bound = QSize(defsize)
        bound.scale(crect.width() - margin,
                    crect.height() - margin, Qt.KeepAspectRatio)

        svgrect = QRectF(0, 0, bound.width(), bound.height())
        svgrect.moveCenter(crect.center())
        self.renderer().render(painter, svgrect)
    def paintEvent(self, event):
        crect = self.rect()
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)

        painter.setBrush(QBrush(Qt.white))
        painter.setPen(QPen(Qt.lightGray, 1.2))
        painter.drawRoundedRect(QRectF(crect).adjusted(2, 2, -2, -2), 2, 2,
                                Qt.AbsoluteSize)

        if self._selected:
            painter.setPen(QPen(QBrush(Qt.red), 2))
        if self._highlighted:
            painter.setBrush(QBrush(Qt.gray,  Qt.FDiagPattern))
        else:
            painter.setBrush(Qt.NoBrush)

        painter.drawRoundedRect(QRectF(crect).adjusted(2, 2, -2, -2), 2, 2,
                                Qt.AbsoluteSize)

        defsize = self.renderer().defaultSize()
        margin = 5

        bound = QSize(defsize)
        bound.scale(crect.width() - margin, crect.height() - margin,
                    Qt.KeepAspectRatio)

        svgrect = QRectF(0, 0, bound.width(), bound.height())
        svgrect.moveCenter(crect.center())
        self.renderer().render(painter, svgrect)
Exemple #3
0
	def paintEvent(self, event):
		painter = QPainter(self)
		painter.setRenderHint(QPainter.Antialiasing)
		size = QSize(1, 1)
		size.scale(self.width() - 1, self.height() - 1, Qt.KeepAspectRatio)

		matrix = QMatrix()
		matrix.translate((self.width() - size.width()) / 2, (self.height() - size.height()) / 2)
		painter.setMatrix(matrix)
		self.__startAngle = 0
		for polozka in self.__polozky:
			self.kresliPolozku(painter, size, polozka[0], polozka[1], polozka[2])
		self.__startAngle = 0
		for polozka in self.__polozky:
			self.kresliText(painter, size, polozka[0], polozka[1], polozka[2])
    def paintEvent(self, event):
        """
        On paint event

        @param txt: 
        @type txt:
        """
        painter = QPainter(self)
        painter.setRenderHint(QPainter.Antialiasing)
        size = QSize(1, 1)
        size.scale(self.width() - 1, self.height() - 1, Qt.KeepAspectRatio)

        matrix = QTransform()
        matrix.translate((self.width() - size.width()) / 2,
                         (self.height() - size.height()) / 2)
        painter.setWorldTransform(matrix)

        self.__startAngle = 0
        for __data in self.__datas:
            self.drawData(painter, size, __data[0], __data[1], __data[2])
        self.__startAngle = 0
        for __data in self.__datas:
            self.drawText(painter, size, __data[0], __data[1], __data[2])