本文整理匯總了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]))