コード例 #1
0
    def drawShape(self, painter):
        borderWidth = 1
        x = borderWidth / 2.0
        y = borderWidth / 2.0
        w = self.width() - borderWidth
        h = self.height() - borderWidth

        # round radius and outline width
        if self.height() < self.width():
            rr = self.height() * 0.20
            ow = self.height() * 0.33
        else:
            rr = self.width() * 0.20
            ow = self.width() * 0.33

        pathOuter = QtGui.QPainterPath()
        pathOuter.addRoundedRect(QtCore.QRectF(x, y, w, h), rr, rr)

        innX = x + ow
        innY = y + ow
        innW = w - (ow * 2)
        innH = h - (ow * 2)
        innR = rr * 0.2
        pathInner = QtGui.QPainterPath()
        pathInner.addRoundedRect(QtCore.QRectF(innX, innY, innW, innH), innR,
                                 innR)

        self.drawPathWithBorder(painter, pathOuter - pathInner, borderWidth)
コード例 #2
0
    def drawShape(self, painter):
        borderWidth = 1
        x = borderWidth / 2.0
        y = borderWidth / 2.0
        w = self.width() - borderWidth
        h = self.height() - borderWidth

        path = QtGui.QPainterPath()
        path.addEllipse(QtCore.QRectF(x, y, w, h))
        self.drawPathWithBorder(painter, path, borderWidth)
コード例 #3
0
ファイル: widgets.py プロジェクト: Gotetz/mgear
    def drawShape(self, painter):
        borderWidth = 1
        w = self.width() - borderWidth
        h = self.height() - borderWidth

        triangle = QtGui.QPolygon([QtCore.QPoint(-1, 0),
                                  QtCore.QPoint(-1, h - 1),
                                  QtCore.QPoint(w - 1, h / 2)])
        path = QtGui.QPainterPath()
        path.addPolygon(triangle)
        self.drawPathWithBorder(painter, path, borderWidth)
        painter.setClipRegion(triangle, QtCore.Qt.ReplaceClip)
コード例 #4
0
    def drawShape(self, painter):
        borderWidth = 1
        x = borderWidth / 2.0
        y = borderWidth / 2.0
        w = self.width() - borderWidth
        h = self.height() - borderWidth

        path = QtGui.QPainterPath()
        path.addEllipse(QtCore.QRectF(x, y, w, h))

        if self.height() < self.width():
            ow = self.height() * 0.25
        else:
            ow = self.width() * 0.25

        innX = x + ow
        innY = y + ow
        innW = w - (ow * 2)
        innH = h - (ow * 2)
        pathInner = QtGui.QPainterPath()
        pathInner.addEllipse(QtCore.QRectF(innX, innY, innW, innH))
        self.drawPathWithBorder(painter, path - pathInner, borderWidth)
コード例 #5
0
    def drawShape(self, painter):
        borderWidth = 1
        x = borderWidth / 2.0
        y = borderWidth / 2.0
        w = self.width() - borderWidth
        h = self.height() - borderWidth

        # round radius
        if self.height() < self.width():
            rr = self.height() * 0.20
        else:
            rr = self.width() * 0.20

        path = QtGui.QPainterPath()
        path.addRoundedRect(QtCore.QRectF(x, y, w, h), rr, rr)
        self.drawPathWithBorder(painter, path, borderWidth)