本文整理汇总了Python中PySide.QtTest.QTest.keyClick方法的典型用法代码示例。如果您正苦于以下问题:Python QTest.keyClick方法的具体用法?Python QTest.keyClick怎么用?Python QTest.keyClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtTest.QTest
的用法示例。
在下文中一共展示了QTest.keyClick方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_place_item
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import keyClick [as 别名]
def test_place_item(self):
"""
Tests the workflow of placing an item
"""
# Make sure the dockwidget is out of the way
self.mw.history_dock_widget.hide()
# Select insertion mode
QTest.keyClick(self.mw, QtCore.Qt.Key_F2)
self.app.processEvents()
# Place item
QTest.mouseClick(
self.mw._view.viewport(),
QtCore.Qt.LeftButton,
pos=self.mw._view.geometry().center()
)
self.app.processEvents()
logic_item_count = 0
for item in self.mw._view.scene().items():
if isinstance(item, logicitems.LogicItem):
logic_item_count += 1
self.assertEqual(1, logic_item_count)
示例2: keyClick
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import keyClick [as 别名]
def keyClick(self, widget, key, modifier=qt.Qt.NoModifier, delay=-1):
"""Simulate clicking a key.
See QTest.keyClick for details.
"""
QTest.keyClick(widget, key, modifier, delay)
self.qWait(20)
示例3: testKeyEvent
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import keyClick [as 别名]
def testKeyEvent(self):
widget = QLineEdit()
key = Qt.Key_A
eventFilter = KeyEventFilter(widget, QEvent.KeyPress, key)
widget.installEventFilter(eventFilter)
QTest.keyClick(widget, key)
self.assert_(eventFilter.processed)
示例4: check_open_and_dismiss
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import keyClick [as 别名]
def check_open_and_dismiss(window):
nonlocal called
self.assertIsInstance(window, QtGui.QMessageBox)
QTest.keyClick(window, QtCore.Qt.Key_Escape)
QtGui.QApplication.instance().processEvents()
called = True
示例5: testKeyboardControls
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import keyClick [as 别名]
def testKeyboardControls(self):
QTest.keyClick(self.vs, Qt.Key_0)
QTest.keyClick(self.vs, Qt.Key_Space)
self.main.sendInputToOutput.assert_called_with(0, 0)
QTest.keyClick(self.vs, Qt.Key_1)
self.preview.sendInputToOutput.assert_called_with(1, 1)
QTest.keyClick(self.vs, Qt.Key_Space)
self.main.sendInputToOutput.assert_called_with(1, 0)
QTest.keyClick(self.vs, Qt.Key_2)
self.preview.sendInputToOutput.assert_called_with(2, 1)
QTest.keyClick(self.vs, Qt.Key_Space)
self.main.sendInputToOutput.assert_called_with(2, 0)
QTest.keyClick(self.vs, Qt.Key_3)
self.preview.sendInputToOutput.assert_called_with(3, 1)
QTest.keyClick(self.vs, Qt.Key_Space)
self.main.sendInputToOutput.assert_called_with(3, 0)
QTest.keyClick(self.vs, Qt.Key_4)
self.preview.sendInputToOutput.assert_called_with(4, 1)
QTest.keyClick(self.vs, Qt.Key_Space)
self.main.sendInputToOutput.assert_called_with(4, 0)
QTest.keyClick(self.vs, Qt.Key_5)
self.preview.sendInputToOutput.assert_called_with(6, 1)
QTest.keyClick(self.vs, Qt.Key_Space)
self.main.sendInputToOutput.assert_called_with(5, 0)
QTest.keyClick(self.vs, Qt.Key_6)
self.preview.sendInputToOutput.assert_called_with(5, 1)
QTest.keyClick(self.vs, Qt.Key_Space)
self.main.sendInputToOutput.assert_called_with(6, 0)
self.main.sendInputToOutput.reset_mock()
self.preview.sendInputToOutput.reset_mock()
QTest.keyClick(self.vs, Qt.Key_7)
self.assertFalse(self.preview.sendInputToOutput.called)
QTest.keyClick(self.vs, Qt.Key_Space)
self.main.sendInputToOutput.assert_called_with(6, 0) # which was the last valid input key pressed