本文整理汇总了Python中pyqode.qt.QtTest.QTest.keyPress方法的典型用法代码示例。如果您正苦于以下问题:Python QTest.keyPress方法的具体用法?Python QTest.keyPress怎么用?Python QTest.keyPress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqode.qt.QtTest.QTest
的用法示例。
在下文中一共展示了QTest.keyPress方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_splittable_codedit_tab_widget
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def test_splittable_codedit_tab_widget():
tw = SplittableCodeEditTabWidget()
tw.show()
nd = tw.create_new_document()
QTest.keyPress(nd, 'a')
w_file = tw.open_document(__file__)
QTest.qWait(1000)
other = tw.open_document(server.__file__)
assert tw.current_widget() == other
assert other != w_file
assert tw.open_document(__file__) == w_file
QTest.qWait(1000)
assert tw.count() == 3
tw.rename_document(__file__, __file__ + '.old')
QTest.qWait(1000)
tw.close_document(__file__ + '.old')
QTest.qWait(1000)
assert tw.count() == 2
tw.close_document(server.__file__)
QTest.qWait(1000)
assert tw.count() == 1
tw.close_all()
QTest.qWait(1000)
assert tw.count() == 0
tw.close()
del tw
示例2: reject_mbox
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def reject_mbox():
print('reject')
widgets = QtWidgets.QApplication.instance().topLevelWidgets()
for w in widgets:
print(w)
if isinstance(w, QtWidgets.QDialog):
QTest.keyPress(w, QtCore.Qt.Key_Escape)
示例3: test_key_pressed
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def test_key_pressed(editor):
editor.free_format = False
editor.comment_indicator = '*> '
editor.setPlainText('123456DISPLAY "Hello".', '', '')
QTest.keyPress(editor, QtCore.Qt.Key_Slash, QtCore.Qt.ControlModifier)
assert editor.toPlainText() == '123456*> DISPLAY "Hello".'
QTest.keyPress(editor, QtCore.Qt.Key_Slash, QtCore.Qt.ControlModifier)
assert editor.toPlainText() == '123456DISPLAY "Hello".'
示例4: test_calltips
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def test_calltips(editor):
editor.clear()
mode = get_mode(editor)
assert editor.backend.connected
assert mode is not None
editor.setPlainText("open(__file_")
TextHelper(editor).goto_line(1, len('open(__file_'))
QTest.keyPress(editor, ',')
QTest.keyRelease(editor, ',')
QTest.qWait(1000)
示例5: run
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def run(self, editor):
editor.setPlainText(self.context.input_code, '', '')
TextHelper(editor).goto_line(self.context.input_line,
self.context.input_column)
wait = 1
QTest.qWait(wait)
QTest.keyPress(editor, QtCore.Qt.Key_Return)
QTest.qWait(wait)
assert editor.toPlainText() == self.context.expected_code
assert TextHelper(editor).current_line_nbr() == self.context.expected_line
assert TextHelper(editor).current_column_nbr() == self.context.expected_column
示例6: test_calltips_with_closing_paren
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def test_calltips_with_closing_paren(editor):
editor.clear()
mode = get_mode(editor)
assert editor.backend.connected
assert mode is not None
editor.setPlainText("open")
TextHelper(editor).goto_line(1, len('open'))
QTest.keyPress(editor, '(')
QTest.keyRelease(editor, '(')
QTest.qWait(1000)
mode._display_tooltip(None, 0)
示例7: test_event_filter
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def test_event_filter(editor):
panel = get_panel(editor)
panel.on_actionActionSearchAndReplace_triggered()
panel.request_search('import')
QTest.qWait(5000)
QTest.keyPress(panel.lineEditSearch, QtCore.Qt.Key_Tab)
QTest.keyPress(panel.lineEditSearch, QtCore.Qt.Key_Return)
QTest.keyPress(panel.lineEditReplace, QtCore.Qt.Key_Return)
QTest.keyPress(panel.lineEditReplace, QtCore.Qt.Key_Return,
QtCore.Qt.ControlModifier)
QTest.keyPress(panel.lineEditSearch, QtCore.Qt.Key_Escape)
assert not panel.isVisible()
示例8: test_key_pressed
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def test_key_pressed():
# " -> ""
editor = CodeEdit()
editor.modes.append(modes.AutoCompleteMode())
editor.setPlainText('', '', 'utf-8')
QTest.keyPress(editor, '"')
assert editor.toPlainText() == '""'
editor.clear()
# if a " already exists, cursor should just move after " and a new " should
# not be inserted
editor.setPlainText('"', 'text/x-python', 'utf-8')
TextHelper(editor).goto_line(0, 0)
QTest.keyPress(editor, '"')
assert editor.toPlainText() == '"'
editor.clear()
# if a ) already exists, cursor should just move after ) and a new ) should
# not be inserted
editor.setPlainText(')', 'text/x-python', 'utf-8')
TextHelper(editor).goto_line(0, 0)
QTest.keyPress(editor, ')')
QTest.qWait(1000)
assert editor.toPlainText() == ')'
# ] should be inserted ")" -> "])"
TextHelper(editor).goto_line(0, 0)
QTest.keyPress(editor, ']')
QTest.qWait(1000)
assert editor.toPlainText() == '])'
示例9: test_event_filter
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def test_event_filter(editor):
panel = get_panel(editor)
panel.on_search_and_replace()
panel.request_search('import')
QTest.qWait(1000)
QTest.keyPress(panel.lineEditSearch, QtCore.Qt.Key_Tab)
QTest.keyPress(panel.lineEditSearch, QtCore.Qt.Key_Return)
QTest.keyPress(panel.lineEditReplace, QtCore.Qt.Key_Return)
QTest.keyPress(panel.lineEditReplace, QtCore.Qt.Key_Return,
QtCore.Qt.ControlModifier)
QTest.keyPress(panel.lineEditSearch, QtCore.Qt.Key_Escape)
editor.show()
QTest.qWait(1000)
assert not panel.isVisible()
示例10: test_key_events
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def test_key_events(editor):
zoom = editor.zoom_level
QTest.keyPress(editor, '+', QtCore.Qt.ControlModifier)
assert editor.zoom_level > zoom
QTest.keyPress(editor, '0', QtCore.Qt.ControlModifier)
assert editor.zoom_level == zoom == 0
QTest.keyPress(editor, '-', QtCore.Qt.ControlModifier)
assert editor.zoom_level < zoom
if os.environ['QT_API'].lower() == 'pyqt5':
editor.wheelEvent(QtGui.QWheelEvent(
QtCore.QPoint(10, 10), editor.mapToGlobal(QtCore.QPoint(10, 10)),
QtCore.QPoint(0, 1), QtCore.QPoint(0, 1), 1,
QtCore.Qt.Vertical, QtCore.Qt.MidButton, QtCore.Qt.ControlModifier))
else:
editor.wheelEvent(QtGui.QWheelEvent(
QtCore.QPoint(10, 10), 1,
QtCore.Qt.MidButton, QtCore.Qt.ControlModifier))
if os.environ['QT_API'].lower() == 'pyqt5':
editor.wheelEvent(QtGui.QWheelEvent(
QtCore.QPoint(10, 10), editor.mapToGlobal(QtCore.QPoint(10, 10)),
QtCore.QPoint(0, -1), QtCore.QPoint(0, -1), -1,
QtCore.Qt.Vertical, QtCore.Qt.MidButton, QtCore.Qt.ControlModifier))
else:
editor.wheelEvent(QtGui.QWheelEvent(
QtCore.QPoint(10, 10), -1,
QtCore.Qt.MidButton, QtCore.Qt.ControlModifier))
示例11: perform_actions
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def perform_actions(self, editor):
for action in self.actions:
if action.startswith('goto_line('):
p = re.compile(r'\b\d+\b')
matches = list(p.finditer(action))
assert len(matches) == 2
line = int(matches[0].group())
column = int(matches[1].group())
TextHelper(editor).goto_line(line - 1, column)
elif action.startswith('press('):
p = re.compile(r'\b\d+\b')
matches = list(p.finditer(action))
assert len(matches) == 1
key = int(matches[0].group())
QTest.keyPress(editor, key)
elif action.startswith('assert_nb_children('):
p = re.compile(r'\b\d+\b')
matches = list(p.finditer(action))
assert len(matches) == 1
nb = int(matches[0].group())
scope = self._get_scope(editor)
assert len(list(scope.child_regions())) == nb
elif action == 'fold':
scope = self._get_scope(editor)
scope.fold()
assert scope.collapsed
elif action == 'unfold':
scope = self._get_scope(editor)
scope.unfold()
assert not scope.collapsed
elif action == 'assert_parent':
scope = self._get_scope(editor)
assert scope.parent() is not None
elif action == 'assert_no_parent':
scope = self._get_scope(editor)
assert scope.parent() is None
elif action == 'assert_not_scope_start':
scope = self._get_scope(editor)
assert scope is None
示例12: accept_mbox
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def accept_mbox():
print('accept')
widgets = QtWidgets.QApplication.instance().topLevelWidgets()
for w in widgets:
print(w)
if isinstance(w, QtWidgets.QDialog):
QTest.keyPress(w, QtCore.Qt.Key_Return)
QTest.keyPress(w, QtCore.Qt.Key_Enter)
QTest.keyPress(w, QtCore.Qt.Key_Space)
示例13: accept_dlg
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def accept_dlg():
global flg_multi
flg_multi = True
widgets = QtWidgets.QApplication.instance().topLevelWidgets()
for w in widgets:
if isinstance(w, QtWidgets.QDialog):
QTest.keyPress(w, QtCore.Qt.Key_Tab)
QTest.keyPress(w, QtCore.Qt.Key_Tab)
QTest.keyPress(w, QtCore.Qt.Key_Return)
示例14: test_key_pressed
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def test_key_pressed(editor):
QTest.keyPress(editor, '"')
editor.clear()
editor.setPlainText('"', 'text/x-python', 'utf-8')
TextHelper(editor).goto_line(0, 0)
QTest.keyPress(editor, '"')
editor.clear()
editor.setPlainText(')', 'text/x-python', 'utf-8')
TextHelper(editor).goto_line(0, 0)
QTest.keyPress(editor, ')')
示例15: test_quoting_selection
# 需要导入模块: from pyqode.qt.QtTest import QTest [as 别名]
# 或者: from pyqode.qt.QtTest.QTest import keyPress [as 别名]
def test_quoting_selection(editor):
editor.setPlainText('foo', '', 'utf-8')
TextHelper(editor).goto_line(0, 0)
editor.selectAll()
QTest.keyPress(editor, '(')
assert editor.toPlainText() == '(foo)'