当前位置: 首页>>代码示例>>Python>>正文


Python QTextEdit.keyPressEvent方法代码示例

本文整理汇总了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)
开发者ID:089git,项目名称:calibre,代码行数:14,代码来源:console.py

示例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)
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:17,代码来源:PM_TextEdit.py


注:本文中的PyQt4.Qt.QTextEdit.keyPressEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。