本文整理汇总了Python中PyQt4.QtGui.QGraphicsSimpleTextItem.rotate方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsSimpleTextItem.rotate方法的具体用法?Python QGraphicsSimpleTextItem.rotate怎么用?Python QGraphicsSimpleTextItem.rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QGraphicsSimpleTextItem
的用法示例。
在下文中一共展示了QGraphicsSimpleTextItem.rotate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_y_axis
# 需要导入模块: from PyQt4.QtGui import QGraphicsSimpleTextItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsSimpleTextItem import rotate [as 别名]
def draw_y_axis(self):
lineItem = QGraphicsLineItem(0, self.coordY(self.ylim[0]),
0, self.coordY(self.ylim[1]),
parent=self.item)
lineItem.setPen(QPen(QColor('black')))
lineItem.setZValue(10)
max_w = 0
for y in set(self.hlines + list(self.ylim)):
lineItem = QGraphicsLineItem(0, self.coordY(y),
-5, self.coordY(y),
parent=self.item)
lineItem.setPen(QPen(QColor('black')))
lineItem.setZValue(10)
text = QGraphicsSimpleTextItem(str(y))
text.setFont(QFont("Arial", self.fsize-2))
text.setParentItem(self.item)
tw = text.boundingRect().width()
max_w = tw if tw > max_w else max_w
th = text.boundingRect().height()
# Center text according to masterItem size
text.setPos(-tw - 5, self.coordY(y)-th/2)
if self.ylabel:
text = QGraphicsSimpleTextItem(self.ylabel)
text.setFont(QFont("Arial", self.fsize-1))
text.setParentItem(self.item)
text.rotate(-90)
tw = text.boundingRect().width()
th = text.boundingRect().height()
# Center text according to masterItem size
text.setPos(-th -5-max_w, tw/2+self.coordY(sum(self.ylim)/2))
示例2: draw_x_axis
# 需要导入模块: from PyQt4.QtGui import QGraphicsSimpleTextItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsSimpleTextItem import rotate [as 别名]
def draw_x_axis(self):
#lineItem = QGraphicsLineItem(self.col_w/2,
# self.coordY(self.ylim[0])+2,
# self.width-self.col_w/2,
# self.coordY(self.ylim[0])+2,
# parent=self.item)
#lineItem.setPen(QPen(QColor('black')))
#lineItem.setZValue(10)
#all_vals = list(range(0, len(self.values), 5))
#if (len(self.values)-1)%5:
# all_vals += [len(self.values)-1]
for x, lab in enumerate(self.values):
# lineItem = QGraphicsLineItem(0, self.coordY(self.ylim[0])+2,
# 0, self.coordY(self.ylim[0])+6,
# parent=self.item)
# lineItem.setX(x*self.col_w + self.col_w/2)
# lineItem.setPen(QPen(QColor('black')))
# lineItem.setZValue(10)
text = QGraphicsSimpleTextItem(str(lab))
text.rotate(-90)
text.setFont(QFont("Arial", self.fsize-2))
text.setParentItem(self.item)
tw = text.boundingRect().height()
# Center text according to masterItem size
text.setPos(x*self.col_w-tw/2 + self.col_w/2,
self.coordY(self.ylim[0]))