本文整理汇总了Python中AnyQt.QtWidgets.QGraphicsTextItem.setRotation方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsTextItem.setRotation方法的具体用法?Python QGraphicsTextItem.setRotation怎么用?Python QGraphicsTextItem.setRotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QGraphicsTextItem
的用法示例。
在下文中一共展示了QGraphicsTextItem.setRotation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWAxis
# 需要导入模块: from AnyQt.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from AnyQt.QtWidgets.QGraphicsTextItem import setRotation [as 别名]
#.........这里部分代码省略.........
return
self.line_item.setLine(self.graph_line)
self.line_item.setPen(line_color)
if self.title:
self.title_item.setHtml('<b>' + self.title + '</b>')
self.title_item.setDefaultTextColor(text_color)
if self.title_location == AxisMiddle:
title_p = 0.5
elif self.title_location == AxisEnd:
title_p = 0.95
else:
title_p = 0.05
title_pos = self.graph_line.pointAt(title_p)
v = self.graph_line.normalVector().unitVector()
dense_text = False
if hasattr(self, 'title_margin'):
offset = self.title_margin
elif self._ticks:
if self.should_be_expanded():
offset = 55
dense_text = True
else:
offset = 35
else:
offset = 10
if self.title_above:
title_pos += (v.p2() - v.p1()) * (offset + QFontMetrics(self.title_item.font()).height())
else:
title_pos -= (v.p2() - v.p1()) * offset
## TODO: Move it according to self.label_pos
self.title_item.setVisible(self.show_title)
self.title_item.setRotation(-self.graph_line.angle())
c = self.title_item.mapToParent(self.title_item.boundingRect().center())
tl = self.title_item.mapToParent(self.title_item.boundingRect().topLeft())
self.title_item.setPos(title_pos - c + tl)
## Arrows
if not zoom_only:
if self.start_arrow_item:
self.scene().removeItem(self.start_arrow_item)
self.start_arrow_item = None
if self.end_arrow_item:
self.scene().removeItem(self.end_arrow_item)
self.end_arrow_item = None
if self.arrows & AxisStart:
if not zoom_only or not self.start_arrow_item:
self.start_arrow_item = QGraphicsPathItem(self.arrow_path, self)
self.start_arrow_item.setPos(self.graph_line.p1())
self.start_arrow_item.setRotation(-self.graph_line.angle() + 180)
self.start_arrow_item.setBrush(line_color)
self.start_arrow_item.setPen(line_color)
if self.arrows & AxisEnd:
if not zoom_only or not self.end_arrow_item:
self.end_arrow_item = QGraphicsPathItem(self.arrow_path, self)
self.end_arrow_item.setPos(self.graph_line.p2())
self.end_arrow_item.setRotation(-self.graph_line.angle())
self.end_arrow_item.setBrush(line_color)
self.end_arrow_item.setPen(line_color)
## Labels
n = len(self._ticks)
resize_plot_item_list(self.label_items, n, QGraphicsTextItem, self)