本文整理汇总了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)
示例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
示例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
示例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()