本文整理汇总了Python中AnyQt.QtGui.QPen.setCosmetic方法的典型用法代码示例。如果您正苦于以下问题:Python QPen.setCosmetic方法的具体用法?Python QPen.setCosmetic怎么用?Python QPen.setCosmetic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QPen
的用法示例。
在下文中一共展示了QPen.setCosmetic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _draw_border
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def _draw_border(point_1, point_2, border_width, parent):
pen = QPen(QColor(self.border_color))
pen.setCosmetic(True)
pen.setWidth(border_width)
line = QGraphicsLineItem(QLineF(point_1, point_2), parent)
line.setPen(pen)
return line
示例2: generate_pens
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def generate_pens(basecolor):
pen = QPen(basecolor, 1)
pen.setCosmetic(True)
shadow_pen = QPen(pen.color().lighter(160), 2.5)
shadow_pen.setCosmetic(True)
return pen, shadow_pen
示例3: _anchor_circle
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def _anchor_circle(self, variables):
# minimum visible anchor radius (radius)
min_radius = self._get_min_radius()
axisitems = []
for anchor, var in zip(self.plotdata.axes, variables[:]):
axitem = AnchorItem(line=QLineF(0, 0, *anchor), text=var.name,)
axitem.setVisible(np.linalg.norm(anchor) > min_radius)
axitem.setPen(pg.mkPen((100, 100, 100)))
axitem.setArrowVisible(True)
self.viewbox.addItem(axitem)
axisitems.append(axitem)
self.plotdata.axisitems = axisitems
if self.placement == self.Placement.Circular:
return
hidecircle = QGraphicsEllipseItem()
hidecircle.setRect(QRectF(-min_radius, -min_radius, 2 * min_radius, 2 * min_radius))
_pen = QPen(Qt.lightGray, 1)
_pen.setCosmetic(True)
hidecircle.setPen(_pen)
self.viewbox.addItem(hidecircle)
self.plotdata.hidecircle = hidecircle
示例4: __init__
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [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)
示例5: _anchor_circle
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def _anchor_circle(self):
# minimum visible anchor radius (radius)
minradius = self.radius / 100 + 1e-5
for item in chain(self.plotdata.anchoritem, self.plotdata.items):
self.viewbox.removeItem(item)
self.plotdata.anchoritem = []
self.plotdata.items = []
for anchor, var in zip(self.plotdata.anchors, self.data.domain.attributes):
if True or np.linalg.norm(anchor) > minradius:
axitem = AnchorItem(
line=QLineF(0, 0, *anchor), text=var.name,)
axitem.setVisible(np.linalg.norm(anchor) > minradius)
axitem.setPen(pg.mkPen((100, 100, 100)))
axitem.setArrowVisible(True)
self.plotdata.anchoritem.append(axitem)
self.viewbox.addItem(axitem)
hidecircle = QGraphicsEllipseItem()
hidecircle.setRect(
QRectF(-minradius, -minradius,
2 * minradius, 2 * minradius))
_pen = QPen(Qt.lightGray, 1)
_pen.setCosmetic(True)
hidecircle.setPen(_pen)
self.viewbox.addItem(hidecircle)
self.plotdata.items.append(hidecircle)
self.plotdata.hidecircle = hidecircle
示例6: paint
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def paint(self, painter, option, widget=None):
painter.save()
palette = self.palette()
border = palette.brush(QPalette.Mid)
pen = QPen(border, 1)
pen.setCosmetic(True)
painter.setPen(pen)
painter.setBrush(palette.brush(QPalette.Window))
brect = self.boundingRect()
painter.drawRoundedRect(brect, 4, 4)
painter.restore()
示例7: __init__
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def __init__(self, size=None, offset=None, pen=None, brush=None):
super().__init__(size, offset)
self.layout.setContentsMargins(5, 5, 5, 5)
self.layout.setHorizontalSpacing(15)
self.layout.setColumnAlignment(1, Qt.AlignLeft | Qt.AlignVCenter)
if pen is None:
pen = QPen(QColor(196, 197, 193, 200), 1)
pen.setCosmetic(True)
self.__pen = pen
if brush is None:
brush = QBrush(QColor(232, 232, 232, 100))
self.__brush = brush
示例8: _setup_plot
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def _setup_plot(self):
target = self.target_index
selected = self.selected_classifiers
curves = [self.plot_curves(target, clf_idx) for clf_idx in selected]
for curve in curves:
self.plot.addItem(curve.curve_item)
if self.display_convex_hull:
hull = convex_hull([c.curve.hull for c in curves])
self.plot.plot(hull[0], hull[1], pen="y", antialias=True)
pen = QPen(QColor(100, 100, 100, 100), 1, Qt.DashLine)
pen.setCosmetic(True)
self.plot.plot([0, 1], [0, 1], pen=pen, antialias=True)
示例9: __updateStyleState
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [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)
示例10: paint
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [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)
示例11: __paint
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def __paint(self):
picture = QPicture()
painter = QPainter(picture)
pen = QPen(QBrush(Qt.white), 0.5)
pen.setCosmetic(True)
painter.setPen(pen)
geom = self.geometry
x, y = geom.x(), geom.y()
w, h = geom.width(), geom.height()
wsingle = w / len(self.dist)
for d, c in zip(self.dist, self.colors):
painter.setBrush(QBrush(c))
painter.drawRect(QRectF(x, y, wsingle, d * h))
x += wsingle
painter.end()
self.__picture = picture
示例12: display_distribution
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def display_distribution(self):
dist = self.distributions
var = self.var
if dist is None or not len(dist):
return
self.plot.clear()
self.plot_prob.clear()
self.ploti.hideAxis('right')
self.tooltip_items = []
bottomaxis = self.ploti.getAxis("bottom")
bottomaxis.setLabel(var.name)
bottomaxis.resizeEvent()
self.set_left_axis_name()
if var and var.is_continuous:
bottomaxis.setTicks(None)
if not len(dist[0]):
return
edges, curve = ash_curve(dist, None, m=OWDistributions.ASH_HIST,
smoothing_factor=self.smoothing_factor)
edges = edges + (edges[1] - edges[0])/2
edges = edges[:-1]
if self.cumulative_distr:
dx = edges[1] - edges[0]
curve = numpy.cumsum(curve) * dx
item = pg.PlotCurveItem()
pen = QPen(QBrush(Qt.white), 3)
pen.setCosmetic(True)
item.setData(edges, curve, antialias=True, stepMode=False,
fillLevel=0, brush=QBrush(Qt.gray), pen=pen)
self.plot.addItem(item)
item.tooltip = "Density"
self.tooltip_items.append((self.plot, item))
else:
bottomaxis.setTicks([list(enumerate(var.values))])
for i, w in enumerate(dist):
geom = QRectF(i - 0.33, 0, 0.66, w)
item = DistributionBarItem(geom, [1.0],
[QColor(128, 128, 128)])
self.plot.addItem(item)
item.tooltip = "Frequency for %s: %r" % (var.values[i], w)
self.tooltip_items.append((self.plot, item))
示例13: plot_curves
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def plot_curves(self, target, clf_idx):
if (target, clf_idx) not in self._curve_data:
curve = liftCurve_from_results(self.results, clf_idx, target)
color = self.colors[clf_idx]
pen = QPen(color, 1)
pen.setCosmetic(True)
shadow_pen = QPen(pen.color().lighter(160), 2.5)
shadow_pen.setCosmetic(True)
item = pg.PlotDataItem(
curve.points[0], curve.points[1],
pen=pen, shadowPen=shadow_pen,
symbol="+", symbolSize=3, symbolPen=shadow_pen,
antialias=True
)
hull_item = pg.PlotDataItem(
curve.hull[0], curve.hull[1],
pen=pen, antialias=True
)
self._curve_data[target, clf_idx] = \
PlotCurve(curve, item, hull_item)
return self._curve_data[target, clf_idx]
示例14: _setup_plot
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def _setup_plot(self):
target = self.target_index
selected = self.selected_classifiers
curves = [self.plot_curves(target, clf_idx) for clf_idx in selected]
for curve in curves:
self.plot.addItem(curve.curve_item)
if self.display_convex_hull:
hull = convex_hull([c.curve.hull for c in curves])
self.plot.plot(hull[0], hull[1], pen="y", antialias=True)
pen = QPen(QColor(100, 100, 100, 100), 1, Qt.DashLine)
pen.setCosmetic(True)
self.plot.plot([0, 1], [0, 1], pen=pen, antialias=True)
warning = ""
if not all(c.curve.is_valid for c in curves):
if any(c.curve.is_valid for c in curves):
warning = "Some lift curves are undefined"
else:
warning = "All lift curves are undefined"
self.warning(warning)
示例15: _make_pen
# 需要导入模块: from AnyQt.QtGui import QPen [as 别名]
# 或者: from AnyQt.QtGui.QPen import setCosmetic [as 别名]
def _make_pen(color, width):
p = QPen(color, width)
p.setCosmetic(True)
return p