本文整理汇总了Python中PyQt5.Qt.QPen.setWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QPen.setWidth方法的具体用法?Python QPen.setWidth怎么用?Python QPen.setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.Qt.QPen
的用法示例。
在下文中一共展示了QPen.setWidth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: paintEvent
# 需要导入模块: from PyQt5.Qt import QPen [as 别名]
# 或者: from PyQt5.Qt.QPen import setWidth [as 别名]
def paintEvent(self, event):
QWidget.paintEvent(self, event)
pmap = self._pixmap
if pmap.isNull():
return
w, h = pmap.width(), pmap.height()
ow, oh = w, h
cw, ch = self.rect().width(), self.rect().height()
scaled, nw, nh = fit_image(w, h, cw, ch)
if scaled:
pmap = pmap.scaled(int(nw*pmap.devicePixelRatio()), int(nh*pmap.devicePixelRatio()), Qt.IgnoreAspectRatio,
Qt.SmoothTransformation)
w, h = int(pmap.width()/pmap.devicePixelRatio()), int(pmap.height()/pmap.devicePixelRatio())
x = int(abs(cw - w)/2.)
y = int(abs(ch - h)/2.)
target = QRect(x, y, w, h)
p = QPainter(self)
p.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
p.drawPixmap(target, pmap)
if self.draw_border:
pen = QPen()
pen.setWidth(self.BORDER_WIDTH)
p.setPen(pen)
p.drawRect(target)
if self.show_size:
draw_size(p, target, ow, oh)
p.end()
示例2: __call__
# 需要导入模块: from PyQt5.Qt import QPen [as 别名]
# 或者: from PyQt5.Qt.QPen import setWidth [as 别名]
def __call__(self, painter, rect, color_theme, title_block, subtitle_block, footer_block):
painter.fillRect(rect, self.color1)
top = title_block.position.y + 2
extra_spacing = subtitle_block.line_spacing // 2 if subtitle_block.line_spacing else title_block.line_spacing // 3
height = title_block.height + subtitle_block.height + extra_spacing + title_block.leading
right = rect.right() - self.hmargin
width = right - self.hmargin
# Draw main banner
p = main = QPainterPath(QPointF(self.hmargin, top))
draw_curved_line(p, rect.width() - 2 * self.hmargin, 0, 0.1, -0.1, 0.9, -0.1)
deltax = self.GRADE * height
p.lineTo(right + deltax, top + height)
right_corner = p.currentPosition()
draw_curved_line(p, - width - 2 * deltax, 0, 0.1, 0.05, 0.9, 0.05)
left_corner = p.currentPosition()
p.closeSubpath()
# Draw fold rectangles
rwidth = self.fold_width
yfrac = 0.1
width23 = int(0.67 * rwidth)
rtop = top + height * yfrac
def draw_fold(x, m=1, corner=left_corner):
ans = p = QPainterPath(QPointF(x, rtop))
draw_curved_line(p, rwidth*m, 0, 0.1, 0.1*m, 0.5, -0.2*m)
fold_upper = p.currentPosition()
p.lineTo(p.currentPosition() + QPointF(-deltax*m, height))
fold_corner = p.currentPosition()
draw_curved_line(p, -rwidth*m, 0, 0.2, -0.1*m, 0.8, -0.1*m)
draw_curved_line(p, deltax*m, -height, 0.2, 0.1*m, 0.8, 0.1*m)
p = inner_fold = QPainterPath(corner)
dp = fold_corner - p.currentPosition()
draw_curved_line(p, dp.x(), dp.y(), 0.5, 0.3*m, 1, 0*m)
p.lineTo(fold_upper), p.closeSubpath()
return ans, inner_fold
left_fold, left_inner = draw_fold(self.hmargin - width23)
right_fold, right_inner = draw_fold(right + width23, m=-1, corner=right_corner)
painter.save()
painter.setRenderHint(QPainter.Antialiasing)
pen = QPen(self.ccolor2)
pen.setWidth(3)
pen.setJoinStyle(Qt.RoundJoin)
painter.setPen(pen)
for r in (left_fold, right_fold):
painter.fillPath(r, QBrush(self.color2))
painter.drawPath(r)
for r in (left_inner, right_inner):
painter.fillPath(r, QBrush(self.color2.darker()))
painter.drawPath(r)
painter.fillPath(main, QBrush(self.color2))
painter.drawPath(main)
painter.restore()
return self.ccolor2, self.ccolor2, self.ccolor1
示例3: paint
# 需要导入模块: from PyQt5.Qt import QPen [as 别名]
# 或者: from PyQt5.Qt.QPen import setWidth [as 别名]
def paint (self,painter,option, widget):
painter.setRenderHints(QtGui.QPainter.Antialiasing)
painter.rotate(self.rotation)
painter.translate(-16,-16) # taille fixe correspondant a la pixmap utilisee pour generer la geometry
painter.scale(1.5,1.5)
if self.isSelected() == True :
pen = QPen(QtCore.Qt.red)
pen.setWidth(1)
else:
pen = QPen(QtCore.Qt.black)
pen.setWidth(1)
painter.setPen(pen)
radialGradient = QRadialGradient(self.size.width()/2, self.size.height()/2,self.size.width()*0.8, self.size.width(), self.size.height())
radialGradient.setColorAt(0.0, QtCore.Qt.white)
#radialGradient.setColorAt(0.2, self.heros.kingdom().color)
if self.view.color_mode == ColorMode.Empire :
color = self.model.empire().color
else :
color = self.model.kingdom().color
radialGradient.setColorAt(0.2, color)
radialGradient.setColorAt(1.0, QtCore.Qt.black)
painter.setBrush(QBrush(radialGradient))
#brush = QBrush(self.color)
#painter.setBrush(brush)
geometry = self.model.empire().geometry
#qDebug("info : map_item Temple : nombre de polygones %d"%len(geometry['polygon']))
for p in geometry['polygon']:
painter.drawPolygon(QPolygon(p))
#
# painter.drawPolygon(self.polygon)
# path = os.path.join(Config().instance.path_to_icons(),'kingdom','32x32')
# path+="/temple_artemis.png"
# print ('path icon',path)
# pix = QPixmap(path)
#
# painter.drawPixmap(-pix.width()/2.0,-pix.height()/2.0,pix)
if self.name_visible == True :
painter.setPen(QPen(QColor('black')))
painter.translate(0,10)
painter.drawText (self.boundingRect(),QtCore.Qt.AlignHCenter|QtCore.Qt.AlignBottom, self.name)
示例4: paintEvent
# 需要导入模块: from PyQt5.Qt import QPen [as 别名]
# 或者: from PyQt5.Qt.QPen import setWidth [as 别名]
def paintEvent(self, event):
QWidget.paintEvent(self, event)
pmap = self._pixmap
if pmap.isNull():
return
w, h = pmap.width(), pmap.height()
ow, oh = w, h
cw, ch = self.rect().width(), self.rect().height()
scaled, nw, nh = fit_image(w, h, cw, ch)
if scaled:
pmap = pmap.scaled(int(nw*pmap.devicePixelRatio()), int(nh*pmap.devicePixelRatio()), Qt.IgnoreAspectRatio,
Qt.SmoothTransformation)
w, h = int(pmap.width()/pmap.devicePixelRatio()), int(pmap.height()/pmap.devicePixelRatio())
x = int(abs(cw - w)/2.)
y = int(abs(ch - h)/2.)
target = QRect(x, y, w, h)
p = QPainter(self)
p.setRenderHints(QPainter.Antialiasing | QPainter.SmoothPixmapTransform)
p.drawPixmap(target, pmap)
if self.draw_border:
pen = QPen()
pen.setWidth(self.BORDER_WIDTH)
p.setPen(pen)
p.drawRect(target)
if self.show_size:
sztgt = target.adjusted(0, 0, 0, -4)
f = p.font()
f.setBold(True)
p.setFont(f)
sz = u'\u00a0%d x %d\u00a0'%(ow, oh)
flags = Qt.AlignBottom|Qt.AlignRight|Qt.TextSingleLine
szrect = p.boundingRect(sztgt, flags, sz)
p.fillRect(szrect.adjusted(0, 0, 0, 4), QColor(0, 0, 0, 200))
p.setPen(QPen(QColor(255,255,255)))
p.drawText(sztgt, flags, sz)
p.end()
示例5: paint
# 需要导入模块: from PyQt5.Qt import QPen [as 别名]
# 或者: from PyQt5.Qt.QPen import setWidth [as 别名]
def paint(self, painter, option, widget):
pen = QPen(Qt.red)
pen.setWidth(2)
painter.setPen(pen)
painter.drawRoundedRect(1, 1, self._width - 3, self._height - 3, 5, 5)