本文整理汇总了Python中PyQt4.QtGui.QGraphicsSimpleTextItem.setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsSimpleTextItem.setSizePolicy方法的具体用法?Python QGraphicsSimpleTextItem.setSizePolicy怎么用?Python QGraphicsSimpleTextItem.setSizePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QGraphicsSimpleTextItem
的用法示例。
在下文中一共展示了QGraphicsSimpleTextItem.setSizePolicy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: replot_experiments
# 需要导入模块: from PyQt4.QtGui import QGraphicsSimpleTextItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsSimpleTextItem import setSizePolicy [as 别名]
def replot_experiments(self):
"""Replot the whole quality plot.
"""
self.scene.clear()
labels = []
max_dist = numpy.nanmax(list(filter(None, self.distances)))
rug_widgets = []
group_pen = QPen(Qt.black)
group_pen.setWidth(2)
group_pen.setCapStyle(Qt.RoundCap)
background_pen = QPen(QColor(0, 0, 250, 150))
background_pen.setWidth(1)
background_pen.setCapStyle(Qt.RoundCap)
main_widget = QGraphicsWidget()
layout = QGraphicsGridLayout()
attributes = self.data.domain.attributes
if self.data is not None:
for (group, indices), dist_vec in zip(self.groups, self.distances):
indices_set = set(indices)
rug_items = []
if dist_vec is not None:
for i, attr in enumerate(attributes):
# Is this a within group distance or background
in_group = i in indices_set
if in_group:
rug_item = ClickableRugItem(dist_vec[i] / max_dist,
1.0, self.on_rug_item_clicked)
rug_item.setPen(group_pen)
tooltip = experiment_description(attr)
rug_item.setToolTip(tooltip)
rug_item.group_index = indices.index(i)
rug_item.setZValue(rug_item.zValue() + 1)
else:
rug_item = ClickableRugItem(dist_vec[i] / max_dist,
0.85, self.on_rug_item_clicked)
rug_item.setPen(background_pen)
tooltip = experiment_description(attr)
rug_item.setToolTip(tooltip)
rug_item.group = group
rug_item.index = i
rug_item.in_group = in_group
rug_items.append(rug_item)
rug_widget = RugGraphicsWidget(parent=main_widget)
rug_widget.set_rug(rug_items)
rug_widgets.append(rug_widget)
label = group_label(self.selected_split_by_labels(), group)
label_item = QGraphicsSimpleTextItem(label, main_widget)
label_item = GraphicsSimpleTextLayoutItem(label_item, parent=layout)
label_item.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
labels.append(label_item)
for i, (label, rug_w) in enumerate(zip(labels, rug_widgets)):
layout.addItem(label, i, 0, Qt.AlignVCenter)
layout.addItem(rug_w, i, 1)
layout.setRowMaximumHeight(i, 30)
main_widget.setLayout(layout)
self.scene.addItem(main_widget)
self.main_widget = main_widget
self.rug_widgets = rug_widgets
self.labels = labels
self.on_view_resize(self.scene_view.size())