本文整理汇总了Python中PyQt4.Qt.QTextEdit.keyPressEvent方法的典型用法代码示例。如果您正苦于以下问题:Python QTextEdit.keyPressEvent方法的具体用法?Python QTextEdit.keyPressEvent怎么用?Python QTextEdit.keyPressEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.Qt.QTextEdit
的用法示例。
在下文中一共展示了QTextEdit.keyPressEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyPressEvent
# 需要导入模块: from PyQt4.Qt import QTextEdit [as 别名]
# 或者: from PyQt4.Qt.QTextEdit import keyPressEvent [as 别名]
def keyPressEvent(self, ev):
text = unicode(ev.text())
key = ev.key()
action = self.key_dispatcher.get(key, None)
if callable(action):
action()
elif key in (Qt.Key_Escape,):
QTextEdit.keyPressEvent(self, ev)
elif text:
self.text_typed(text)
else:
QTextEdit.keyPressEvent(self, ev)
示例2: keyPressEvent
# 需要导入模块: from PyQt4.Qt import QTextEdit [as 别名]
# 或者: from PyQt4.Qt.QTextEdit import keyPressEvent [as 别名]
def keyPressEvent(self, event):
"""
Overrides the superclass method.
"""
#If user hits 'Enter' key (return key), don't do anything.
if event.key() == Qt.Key_Return:
#there is no obvious way to allow only a single line in a
#QTextEdit (we can use some methods that restrict the columnt width
#, line wrapping etc but this is untested when the line contains
# huge umber of characters. Anyway, the following always works
#and fixes bug 2713
if not self._permit_enter_keystroke:
return
QTextEdit.keyPressEvent(self, event)