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


Python QTest.keyClick方法代码示例

本文整理汇总了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)
开发者ID:LogikSim,项目名称:LogikSimPython,代码行数:28,代码来源:test_gui.py

示例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)
开发者ID:CaptainNemoz,项目名称:silx,代码行数:9,代码来源:testutils.py

示例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)
开发者ID:Hasimir,项目名称:PySide,代码行数:11,代码来源:eventfilter_test.py

示例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
开发者ID:LogikSim,项目名称:LogikSimPython,代码行数:8,代码来源:test_gui.py

示例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
开发者ID:staldates,项目名称:aldatesx,代码行数:43,代码来源:TestVideoSwitcher.py


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