本文整理汇总了Python中AnyQt.QtGui.QPen.setWidthF方法的典型用法代码示例。如果您正苦于以下问题:Python QPen.setWidthF方法的具体用法?Python QPen.setWidthF怎么用?Python QPen.setWidthF使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QPen
的用法示例。
在下文中一共展示了QPen.setWidthF方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setWidthF [as 别名]
def __init__(self, tree_node, parent=None, **kwargs):
self.tree_node = tree_node
super().__init__(self._get_rect_attributes(), parent)
self.tree_node.graphics_item = self
self.setTransformOriginPoint(self.boundingRect().center())
self.setRotation(degrees(self.tree_node.square.angle))
self.setBrush(kwargs.get('brush', QColor('#297A1F')))
# The border should be invariant to scaling
pen = QPen(QColor(Qt.black))
pen.setWidthF(0.75)
pen.setCosmetic(True)
self.setPen(pen)
self.setAcceptHoverEvents(True)
self.setZValue(kwargs.get('zvalue', 0))
self.z_step = Z_STEP
# calculate the correct z values based on the parent
if self.tree_node.parent != TreeAdapter.ROOT_PARENT:
p = self.tree_node.parent
# override root z step
num_children = len(p.children)
own_index = [1 if c.label == self.tree_node.label else 0
for c in p.children].index(1)
self.z_step = int(p.graphics_item.z_step / num_children)
base_z = p.graphics_item.zValue()
self.setZValue(base_z + own_index * self.z_step)
示例2: shape
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setWidthF [as 别名]
def shape(self):
if self.__shape is None:
path = self.curvePath()
pen = QPen(self.pen())
pen.setWidthF(max(pen.widthF(), 7.0))
pen.setStyle(Qt.SolidLine)
self.__shape = stroke_path(path, pen)
return self.__shape
示例3: crosshairs
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setWidthF [as 别名]
def crosshairs(color, radius=24, circle=False):
radius = max(radius, 16)
pixmap = QPixmap(radius, radius)
pixmap.fill(Qt.transparent)
painter = QPainter()
painter.begin(pixmap)
painter.setRenderHints(QPainter.Antialiasing)
pen = QPen(QBrush(color), 1)
pen.setWidthF(1.5)
painter.setPen(pen)
if circle:
painter.drawEllipse(2, 2, radius - 2, radius - 2)
painter.drawLine(radius / 2, 7, radius / 2, radius / 2 - 7)
painter.drawLine(7, radius / 2, radius / 2 - 7, radius / 2)
painter.end()
return pixmap
示例4: __updateStyleState
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setWidthF [as 别名]
def __updateStyleState(self):
"""
Update the arrows' brush, pen, ... based on it's state
"""
if self.isSelected():
color = self.__color.darker(150)
pen = QPen(QColor(96, 158, 215), Qt.DashDotLine)
pen.setWidthF(1.25)
pen.setCosmetic(True)
self.__shadow.setColor(pen.color().darker(150))
else:
color = self.__color
pen = QPen(Qt.NoPen)
self.__shadow.setColor(QColor(63, 63, 63, 180))
self.__arrowItem.setBrush(color)
self.__arrowItem.setPen(pen)
示例5: paint
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setWidthF [as 别名]
def paint(self, painter, option, widget=None):
# Override the default selected appearance
if self.isSelected():
option.state ^= QStyle.State_Selected
rect = self.rect()
# this must render before overlay due to order in which it's drawn
super().paint(painter, option, widget)
painter.save()
pen = QPen(QColor(Qt.black))
pen.setWidthF(2)
pen.setCosmetic(True)
pen.setJoinStyle(Qt.MiterJoin)
painter.setPen(pen)
painter.drawRect(rect)
painter.restore()
else:
super().paint(painter, option, widget)
示例6: hoverEnterEvent
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setWidthF [as 别名]
def hoverEnterEvent(self, event):
pen = QPen(self.pen())
pen.setWidthF(3)
self.setPen(pen)
return RugItem.hoverEnterEvent(self, event)