本文整理汇总了Python中AnyQt.QtWidgets.QGraphicsLineItem.setBrush方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsLineItem.setBrush方法的具体用法?Python QGraphicsLineItem.setBrush怎么用?Python QGraphicsLineItem.setBrush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QGraphicsLineItem
的用法示例。
在下文中一共展示了QGraphicsLineItem.setBrush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsLineItem [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsLineItem import setBrush [as 别名]
def __init__(self, name, data_extremes, values, scale, name_offset, offset):
super().__init__()
data_start, data_stop = data_extremes[0], data_extremes[1]
labels = [str(np.round(data_start + (data_stop - data_start) * i /
(self.n_tck - 1), 1)) for i in range(self.n_tck)]
# leading label
font = name.document().defaultFont()
name.setFont(font)
name.setPos(name_offset, -10)
name.setParentItem(self)
# labels
ascending = data_start < data_stop
y_start, y_stop = (self.y_diff, 0) if ascending else (0, self.y_diff)
for i in range(self.n_tck):
text = QGraphicsSimpleTextItem(labels[i], self)
w = text.boundingRect().width()
y = y_start + (y_stop - y_start) / (self.n_tck - 1) * i
text.setPos(-5 - w, y - 8)
tick = QGraphicsLineItem(-2, y, 2, y, self)
# prediction marker
self.dot = Continuous2DMovableDotItem(
self.DOT_RADIUS, scale, offset, values[0], values[-1], y_start, y_stop)
self.dot.tooltip_labels = labels
self.dot.tooltip_values = values
self.dot.setParentItem(self)
h_line = QGraphicsLineItem(values[0] * scale + offset, self.y_diff / 2,
values[-1] * scale + offset, self.y_diff / 2,
self)
pen = QPen(Qt.DashLine)
pen.setBrush(QColor(Qt.red))
h_line.setPen(pen)
self.dot.horizontal_line = h_line
# pylint: disable=unused-variable
# line
line = QGraphicsLineItem(values[0] * scale + offset, y_start,
values[-1] * scale + offset, y_stop,
self)
# ticks
for value in values:
diff_ = np.nan_to_num(values[-1] - values[0])
k = (value - values[0]) / diff_ if diff_ else 0
y_tick = (y_stop - y_start) * k + y_start - self.tick_height / 2
x_tick = value * scale - self.tick_width / 2 + offset
tick = QGraphicsRectItem(
x_tick, y_tick, self.tick_width, self.tick_height,
self)
tick.setBrush(QColor(Qt.black))
# rect
rect = QGraphicsRectItem(
values[0] * scale + offset, -self.y_diff * 0.125,
values[-1] * scale + offset, self.y_diff * 1.25,
self)
pen = QPen(Qt.DotLine)
pen.setBrush(QColor(50, 150, 200, 255))
rect.setPen(pen)
self.setPreferredSize(self.preferredWidth(), self.y_diff * 1.5)