本文整理汇总了Python中PyQt4.QtGui.QGraphicsSimpleTextItem.setY方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsSimpleTextItem.setY方法的具体用法?Python QGraphicsSimpleTextItem.setY怎么用?Python QGraphicsSimpleTextItem.setY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QGraphicsSimpleTextItem
的用法示例。
在下文中一共展示了QGraphicsSimpleTextItem.setY方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display_answer
# 需要导入模块: from PyQt4.QtGui import QGraphicsSimpleTextItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsSimpleTextItem import setY [as 别名]
def display_answer(self, question, answers, correct_answer, description, selected_index, correct):
x, y = self.display_question(question, answers, selected_index, correct) #TODO pass what to check and if right or wrong
y += 50
item = QGraphicsSimpleTextItem("Correct Answer: %s" % correct_answer)
item.setBrush(self.TEXT_COLOR)
font = QFont(self.BOLDISH)
font.setUnderline(True)
item.setFont(font)
item.setX(x)
item.setY(y)
self.qtscene.addItem(item)
self.references.append(item)
y += 60
item = QGraphicsSimpleTextItem(make_pretty(description, 55))
item.setBrush(self.TEXT_COLOR)
item.setFont(self.NORMALISH)
item.setX(x)
item.setY(y)
self.qtscene.addItem(item)
self.references.append(item)
item = QPushButton('Next')
item.clicked.connect(self.on_next)
item.setFont(self.BOLDISH)
item.move(x+700, y)
self.qtscene.addWidget(item)
self.references.append(item)
示例2: __init__
# 需要导入模块: from PyQt4.QtGui import QGraphicsSimpleTextItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsSimpleTextItem import setY [as 别名]
def __init__(self, table, vector, mass=1.0):
"""Documentation here"""
self.name = table.name
self._mediator = Mediator()
# layout widget
x, y = vector.x, vector.y
text = QGraphicsSimpleTextItem('{0} as {1}'.format(self.name, self.alias))
width = text.boundingRect().width()
QGraphicsRectItem.__init__(self, x, y, width + 10, 22)
self.table = table.alias(self.alias)
self.setBrush(Qt.cyan)
self.setPen(Qt.darkCyan)
self.width = width + 10
self.height = 22
self.setFlag(self.ItemIsSelectable, True)
text.setParentItem(self)
text.setX(x + 5)
text.setY(y + 5)
self.point = vector
self.mass = mass
self.velocity = Vector(0, 0)
self.force = Vector(0, 0)
self.instances.append(self)
示例3: display_question
# 需要导入模块: from PyQt4.QtGui import QGraphicsSimpleTextItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsSimpleTextItem import setY [as 别名]
def display_question(self, question, answers, selected_index = None, correct = None):
self._init_scene()
x = 50
y = 25
item = QGraphicsSimpleTextItem(question)
item.setBrush(self.TEXT_COLOR)
item.setFont(self.BOLDISH)
item.setX(x)
item.setY(y)
self.qtscene.addItem(item)
self.references.append(item)
y += 75
for index, answer in enumerate(answers):
index += 1
item = QGraphicsSimpleTextItem("%s) %s" % (index, answer))
item.setBrush(self.TEXT_COLOR)
item.setFont(self.NORMALISH)
item.setX(x)
item.setY(y)
item.setAcceptHoverEvents(True)
self.qtscene.addItem(item)
self.references.append(item)
#TODO: do not register click but do show check or not
if not selected_index:
item.hoverEnterEvent = partial(self.on_hover_answer, item)
item.hoverLeaveEvent = partial(self.on_unhover_answer, item)
item.mousePressEvent = partial(self.on_click_answer, index)
elif selected_index == index:
if correct:
item = QGraphicsSimpleTextItem(u"\u2713")
item.setBrush(QBrush(QColor(0,150,0)))
item.setX(0)
else:
item = QGraphicsSimpleTextItem("X")
item.setBrush(QBrush(QColor(255,0,0)))
item.setX(3)
item.setFont(self.BOLDISH)
item.setY(y)
self.qtscene.addItem(item)
self.references.append(item)
y += 50
return x, y