本文整理汇总了Python中AnyQt.QtTest.QTest.keyPress方法的典型用法代码示例。如果您正苦于以下问题:Python QTest.keyPress方法的具体用法?Python QTest.keyPress怎么用?Python QTest.keyPress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtTest.QTest
的用法示例。
在下文中一共展示了QTest.keyPress方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hold_modifiers
# 需要导入模块: from AnyQt.QtTest import QTest [as 别名]
# 或者: from AnyQt.QtTest.QTest import keyPress [as 别名]
def hold_modifiers(widget, modifiers):
# use some unexisting key
QTest.keyPress(widget, Qt.Key_F35, modifiers)
try:
yield
finally:
QTest.keyRelease(widget, Qt.Key_F35)
示例2: modifiers
# 需要导入模块: from AnyQt.QtTest import QTest [as 别名]
# 或者: from AnyQt.QtTest.QTest import keyPress [as 别名]
def modifiers(self, modifiers):
"""
Context that simulates pressed modifiers
Since QTest.keypress requries pressing some key, we simulate
pressing "BassBoost" that looks exotic enough to not meddle with
anything.
"""
old_modifiers = QApplication.keyboardModifiers()
try:
QTest.keyPress(self.widget, Qt.Key_BassBoost, modifiers)
yield
finally:
QTest.keyRelease(self.widget, Qt.Key_BassBoost, old_modifiers)