本文整理汇总了Python中AnyQt.QtWidgets.QGraphicsLineItem.setParentItem方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsLineItem.setParentItem方法的具体用法?Python QGraphicsLineItem.setParentItem怎么用?Python QGraphicsLineItem.setParentItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QGraphicsLineItem
的用法示例。
在下文中一共展示了QGraphicsLineItem.setParentItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWNomogram
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsLineItem [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsLineItem import setParentItem [as 别名]
#.........这里部分代码省略.........
diff_ = np.nan_to_num(max_p - min_p)
scale_x = max_width / diff_ if diff_ else max_width
nomogram_header = NomogramItem()
point_item = RulerItem(point_text, values, scale_x, name_offset,
- scale_x * min_p)
point_item.setPreferredSize(point_item.preferredWidth(), 35)
nomogram_header.add_items([point_item])
self.nomogram_main = NomogramItem()
cont_feature_item_class = ContinuousFeature2DItem if \
self.cont_feature_dim_index else ContinuousFeatureItem
feature_items = [
DiscreteFeatureItem(
name_item, attr.values, point,
scale_x, name_offset, - scale_x * min_p)
if attr.is_discrete else
cont_feature_item_class(
name_item, self.log_reg_cont_data_extremes[i][cls_index],
self.get_ruler_values(
point.min(), point.max(),
scale_x * point.ptp(), False),
scale_x, name_offset, - scale_x * min_p)
for i, attr, name_item, point in zip(attr_inds, attributes, name_items, points)]
self.nomogram_main.add_items(feature_items)
self.feature_items = OrderedDict(sorted(zip(attr_inds, feature_items)))
x = - scale_x * min_p
y = self.nomogram_main.layout().preferredHeight() + 10
self.vertical_line = QGraphicsLineItem(x, -6, x, y)
self.vertical_line.setPen(QPen(Qt.DotLine))
self.vertical_line.setParentItem(point_item)
self.hidden_vertical_line = QGraphicsLineItem(x, -6, x, y)
pen = QPen(Qt.DashLine)
pen.setBrush(QColor(Qt.red))
self.hidden_vertical_line.setPen(pen)
self.hidden_vertical_line.setParentItem(point_item)
return point_item, nomogram_header
def get_ordered_attributes(self):
"""Return (in_domain_index, attr) pairs, ordered by method in SortBy combo"""
if self.domain is None or not self.domain.attributes:
return []
attrs = self.domain.attributes
sort_by = self.sort_index
class_value = self.target_class_index
if sort_by == SortBy.NO_SORTING:
return list(enumerate(attrs))
elif sort_by == SortBy.NAME:
def key(x):
_, attr = x
return attr.name.lower()
elif sort_by == SortBy.ABSOLUTE:
def key(x):
i, attr = x
if attr.is_discrete:
ptp = self.points[i][class_value].ptp()