本文整理汇总了Python中PyQt5.QtWidgets.QGraphicsTextItem.focusOutEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QGraphicsTextItem.focusOutEvent方法的具体用法?Python QGraphicsTextItem.focusOutEvent怎么用?Python QGraphicsTextItem.focusOutEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QGraphicsTextItem
的用法示例。
在下文中一共展示了QGraphicsTextItem.focusOutEvent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: focusOutEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsTextItem import focusOutEvent [as 别名]
def focusOutEvent(self, event):
'''Handle focus out event.
Argument(s):
event (QFocusEvent ): Focus event
'''
QGraphicsTextItem.focusOutEvent(self, event)
# Create a fake node to test if label is valid with pydot
fakeNode = ("fake[" + NodeDotAttrs.label.value +
"=" + self.toPlainText() + "]")
pydotGraph = graph_from_dot_data("graph{" + fakeNode + "}")
# Label is valid: we can do the update
if pydotGraph:
dicDotAttrs = {
NodeDotAttrs.label.value:
NodeDotLabelUtils.formatLabel(self.toPlainText())
}
# Update text in other views
node = self.parentItem()
node.graphicsGraphView.controller.onEditNode(node.id, dicDotAttrs)
# Disable edit text
self.setTextInteractionFlags(Qt.NoTextInteraction)
# Label is invalid: force user to write a correct label
else:
QMessageBox.warning(None, "Syntax error",
"The label is invalid.")
self.setFocus()
示例2: focusOutEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsTextItem import focusOutEvent [as 别名]
def focusOutEvent(self, event):
self.inputMethodEvent(event)
QGraphicsTextItem.focusOutEvent(self, event)
示例3: focusOutEvent
# 需要导入模块: from PyQt5.QtWidgets import QGraphicsTextItem [as 别名]
# 或者: from PyQt5.QtWidgets.QGraphicsTextItem import focusOutEvent [as 别名]
def focusOutEvent(self, event):
self.setTextInteractionFlags(Qt.NoTextInteraction)
self.textChanged.emit(self.toPlainText())
self.textEditFinished.emit()
QGraphicsTextItem.focusOutEvent(self, event)