本文整理汇总了Python中PyQt4.QtGui.QGraphicsSimpleTextItem.hoverLeaveEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsSimpleTextItem.hoverLeaveEvent方法的具体用法?Python QGraphicsSimpleTextItem.hoverLeaveEvent怎么用?Python QGraphicsSimpleTextItem.hoverLeaveEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QGraphicsSimpleTextItem
的用法示例。
在下文中一共展示了QGraphicsSimpleTextItem.hoverLeaveEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display_question
# 需要导入模块: from PyQt4.QtGui import QGraphicsSimpleTextItem [as 别名]
# 或者: from PyQt4.QtGui.QGraphicsSimpleTextItem import hoverLeaveEvent [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