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


Python QPainter.drawPath方法代码示例

本文整理汇总了Python中PySide.QtGui.QPainter.drawPath方法的典型用法代码示例。如果您正苦于以下问题:Python QPainter.drawPath方法的具体用法?Python QPainter.drawPath怎么用?Python QPainter.drawPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QPainter的用法示例。


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

示例1: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPath [as 别名]
 def paintEvent(self, pe):
   painter = QPainter(self)
   painter.save()
   gradient = QLinearGradient()
   gradient.setStart(self._grad_start)
   gradient.setFinalStop(self._grad_end)
   gradient.setColorAt(0, QColor(230, 230, 230))
   gradient.setColorAt(1, QColor(247, 247, 247))
   brush = QBrush(gradient)
   painter.setBrush(brush)
   pen = QPen(Qt.black)
   pen.setWidth(1)
   painter.setPen(pen)
   painter.drawPath(self._painter_path)
   painter.restore()
   font = QFont()
   font.setFamily("Tahoma")
   font.setPixelSize(11)
   font.setBold(True)
   pen = QPen(Qt.darkGray)
   painter.setPen(pen)
   painter.setFont(font)
   self_rect = QRect(self.rect())
   self_rect.moveTo(self._hor_margin, self._ver_margin // 2)
   painter.drawText(self_rect, Qt.AlignLeft, self._text)
开发者ID:github-account-because-they-want-it,项目名称:VisualScrape,代码行数:27,代码来源:ui_common.py

示例2: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPath [as 别名]
    def paintEvent(self, event):
        cX = self.parent.leftMargin + self.scaleMarkLen
        cY = self.parent.topMargin + self.scaleMarkLen
        worldX = self.parent.chunkX*16
        worldZ = self.parent.chunkZ*16
        painter = QPainter()
        path = QPainterPath()
        painter.begin(self)
        painter.save()
        #painter.setFont(QFont('Arial Narrow', 8)) #QFont.Bold
        # draw scale
        x = cX
        y = cY
        painter.rotate(-90)
        for i in range(16):
            fr = QRectF(-y, x, self.scaleMarkLen, self.edgeLen)
            painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            painter.drawRect(fr)
            #fr = QRectF(-y - 16*self.edgeLen - self.scaleMarkLen, x, self.scaleMarkLen, self.edgeLen)
            #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            #painter.drawRect(fr)
            x += self.edgeLen
        painter.rotate(90)

        x = self.parent.leftMargin
        y = cY
        for i in range(16):
            fr = QRectF(x, y, self.scaleMarkLen, self.edgeLen)
            painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            painter.drawRect(fr)
            #fr = QRectF(x + self.scaleMarkLen + 16*self.edgeLen, y, self.scaleMarkLen, self.edgeLen)
            #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            #painter.drawRect(fr)
            y += self.edgeLen

        x = cX
        y = cY
        for i in range(16):
            for j in range(16):
                path.addRect(x, y, self.edgeLen, self.edgeLen)
                fr = QRectF(x, y, self.edgeLen, self.edgeLen)
                #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
                x += self.edgeLen
            x = cX
            y += self.edgeLen

        painter.drawPath(path)

        painter.restore()
        painter.end()
        del painter
开发者ID:ydanilin,项目名称:MinecraftMinerals,代码行数:53,代码来源:SliceTest01.py

示例3: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPath [as 别名]
    def paintEvent(self, event):
        cX = self.parent.lytLeftMargin + self.scaleMarkLen
        cY = self.parent.lytTopMargin + self.scaleMarkLen
        worldX = self.parent.presenter.showChunkX*16
        worldZ = self.parent.presenter.showChunkZ*16
        painter = QPainter()
        path = QPainterPath()
        painter.begin(self)
        painter.save()
        #painter.setFont(QFont('Arial Narrow', 8)) #QFont.Bold
        # draw scale
        x = cX
        y = cY
        painter.rotate(-90)
        for i in range(16):
            fr = QRectF(-y, x, self.scaleMarkLen, self.edgeLen)
            painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, str(worldX))
            #painter.drawRect(fr)
            #fr = QRectF(-y - 16*self.edgeLen - self.scaleMarkLen, x, self.scaleMarkLen, self.edgeLen)
            #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            #painter.drawRect(fr)
            x += self.edgeLen
            worldX += 1
        painter.rotate(90)

        x = self.parent.lytLeftMargin
        y = cY
        for i in range(16):
            fr = QRectF(x, y, self.scaleMarkLen, self.edgeLen)
            painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, str(worldZ))
            #painter.drawRect(fr)
            #fr = QRectF(x + self.scaleMarkLen + 16*self.edgeLen, y, self.scaleMarkLen, self.edgeLen)
            #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
            #painter.drawRect(fr)
            y += self.edgeLen
            worldZ += 1

        x = cX
        y = cY
        for i in range(16):
            for j in range(16):
                path.addRect(x, y, self.edgeLen, self.edgeLen)
                #fr = QRectF(x, y, self.edgeLen, self.edgeLen)
                #painter.drawText(fr, Qt.AlignHCenter | Qt.AlignVCenter, '-5555')
                x += self.edgeLen
            x = cX
            y += self.edgeLen
            
        painter.drawPath(path)

        slice_ = self.parent.presenter.getSlice(self.parent.presenter.elevation)
        x = cX
        y = cY
        bru = QBrush()
        #path1 = QPainterPath()
        for i in range(16):
            for j in range(16):
                if slice_[i][j] in self.parent.selectedMinerals.list_:
                    lePen = painter.pen()
                    
                    newPen = QPen(bru, 3)
                    newPen.setColor(self.parent.selectedMinerals.getColor(slice_[i][j]))
                    painter.setPen(newPen)
                    painter.drawRect(x, y, self.edgeLen, self.edgeLen)
                    painter.setPen(lePen)
                x += self.edgeLen
            x = cX
            y += self.edgeLen

        

        painter.restore()
        painter.end()
        del painter
开发者ID:ydanilin,项目名称:MinecraftMinerals,代码行数:76,代码来源:slice.py

示例4: paintEvent

# 需要导入模块: from PySide.QtGui import QPainter [as 别名]
# 或者: from PySide.QtGui.QPainter import drawPath [as 别名]
    def paintEvent(self, event):
        qp = QPainter()
        qp.begin(self)

        qp.setRenderHint(QPainter.Antialiasing)
        qp.setBrush(self.color)
        qp.setPen(self.color)

        rect = event.rect()
        x = rect.x()
        w = rect.width()
        lineheight = 16
        print '-------------------'
        print 'lefts', self.lefts
        print 'rights', self.rights
        print '-------------------'
        ly = self._left_y + 5
        ry = self._right_y + 5
        rs=self.rights[:]

        # offset=1
        for i, l in enumerate(self.lefts):
            path = QPainterPath()
            sl, el = l[0], l[-1]
            try:
                r=rs[i]
                sr, er = r[0], r[-1]
                rs.pop(i)
                # offset+=1
            except IndexError:
                sr, er = l[-1], l[-1]-1

            y = ly + lineheight * sl
            y2 = ry + lineheight * sr

            path.moveTo(x, y)
            path.lineTo(x, y + lineheight * (el - sl + 1))
            path.lineTo(x + w, y2 + lineheight * (er - sr + 1))
            path.lineTo(x + w, y2)
            qp.drawPath(path)

        for i, r in enumerate(rs):
            path = QPainterPath()
            sr, er = r[0], r[-1]
            # try:
            l=self.lefts[i]
            sl, el = r[-1], r[-1]-1
            # except IndexError:
            #     sl, el = l[-1]+2, l[-1]+1
                # print sl, el

            y = ly + lineheight * (sl)
            y2 = ry + lineheight * (sr)

            path.moveTo(x, y)
            path.lineTo(x, y + lineheight * (el - sl + 1))
            path.lineTo(x + w, y2 + lineheight * (er - sr + 1))
            path.lineTo(x + w, y2)
            qp.drawPath(path)

        qp.end()
开发者ID:OSUPychron,项目名称:pychron,代码行数:63,代码来源:diff_editor.py


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