本文整理汇总了Python中qtpy.QtCore.Qt.Key_Return方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.Key_Return方法的具体用法?Python Qt.Key_Return怎么用?Python Qt.Key_Return使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qtpy.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.Key_Return方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyPressEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def keyPressEvent(self, event):
"""Capture Backspace and ESC Keypresses."""
if event.key() == Qt.Key_Escape:
if self.parent().vim_keys.visual_mode:
self.parent().vim_keys.exit_visual_mode()
self.clear()
elif event.key() == Qt.Key_Backspace:
self.setText(self.text() + "\b")
elif event.key() == Qt.Key_Return:
self.setText(self.text() + "\r")
self.parent().on_return()
elif event.key() == Qt.Key_Left and not self.text():
self.setText("h")
elif event.key() == Qt.Key_Right and not self.text():
self.setText("l")
elif event.key() == Qt.Key_Up and not self.text():
self.setText("k")
elif event.key() == Qt.Key_Down and not self.text():
self.setText("j")
else:
QLineEdit.keyPressEvent(self, event)
示例2: keyPressEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def keyPressEvent(self, event):
"""Handle key press event for the dimension slider spinbox.
Parameters
----------
event : qtpy.QtCore.QEvent
Event from the Qt context.
"""
# this is here to intercept Return/Enter keys when editing the FPS
# SpinBox. We WANT the return key to close the popup normally,
# but if the user is editing the FPS spinbox, we simply want to
# register the change and lose focus on the lineEdit, in case they
# want to make an additional change (without reopening the popup)
if event.key() in (Qt.Key_Return, Qt.Key_Enter):
self.editingFinished.emit()
self.clearFocus()
return
super().keyPressEvent(event)
示例3: _get_key_event_handlers
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def _get_key_event_handlers(self):
return {
Qt.Key_Escape: self._handle_escape_key,
Qt.Key_Return: self._handle_enter_key,
Qt.Key_Enter: self._handle_enter_key,
Qt.Key_Backspace: self._handle_backspace_key,
Qt.Key_Delete: self._handle_delete_key,
Qt.Key_Home: self._handle_home_key,
Qt.Key_Tab: self._handle_tab_key,
Qt.Key_Backtab: self._handle_backtab_key,
Qt.Key_Up: self._handle_up_key,
Qt.Key_Down: self._handle_down_key,
Qt.Key_Left: self._handle_left_key,
Qt.Key_D: self._handle_d_key,
Qt.Key_C: self._handle_c_key,
Qt.Key_V: self._handle_v_key,
Qt.Key_U: self._handle_u_key,
}
示例4: test_return_command
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def test_return_command(vim_bot):
"""Move to the start of the next line."""
main, editor_stack, editor, vim, qtbot = vim_bot
editor.stdkey_backspace()
editor.go_to_line(2)
editor.moveCursor(QTextCursor.StartOfLine, QTextCursor.KeepAnchor)
qtbot.keyPress(editor, Qt.Key_Right)
qtbot.keyPress(editor, Qt.Key_Right)
cmd_line = vim.get_focus_widget()
line, _ = editor.get_cursor_line_column()
qtbot.keyPress(cmd_line, Qt.Key_Return)
new_line, _ = editor.get_cursor_line_column()
assert new_line == line + 1
示例5: test_w_command
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def test_w_command(vim_bot):
"""Save file."""
main, editor_stack, editor, vim, qtbot = vim_bot
editor.stdkey_backspace()
editor.go_to_line(3)
cmd_line = vim.get_focus_widget()
qtbot.keyClicks(cmd_line, ':w')
qtbot.keyPress(cmd_line, Qt.Key_Return)
main.editor.save_action.trigger.assert_called_once_with()
示例6: test_q_command
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def test_q_command(vim_bot):
"""Close file."""
main, editor_stack, editor, vim, qtbot = vim_bot
editor.stdkey_backspace()
editor.go_to_line(3)
cmd_line = vim.get_focus_widget()
qtbot.keyClicks(cmd_line, ':q')
qtbot.keyPress(cmd_line, Qt.Key_Return)
main.editor.close_action.trigger.assert_called_once_with()
示例7: test_wq_command
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def test_wq_command(vim_bot):
"""Save and Close file."""
main, editor_stack, editor, vim, qtbot = vim_bot
editor.stdkey_backspace()
editor.go_to_line(3)
cmd_line = vim.get_focus_widget()
qtbot.keyClicks(cmd_line, ':wq')
qtbot.keyPress(cmd_line, Qt.Key_Return)
main.editor.close_action.trigger.assert_called_once_with()
main.editor.save_action.trigger.assert_called_once_with()
示例8: test_e_command_args
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def test_e_command_args(vim_bot):
"""Reload and open file."""
main, editor_stack, editor, vim, qtbot = vim_bot
editor.stdkey_backspace()
editor.go_to_line(3)
cmd_line = vim.get_focus_widget()
qtbot.keyClicks(cmd_line, ':e .')
qtbot.keyPress(cmd_line, Qt.Key_Return)
main.editor.open_action.trigger.assert_called_once_with()
示例9: test_colon_number_command
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def test_colon_number_command(vim_bot):
"""Go to line."""
main, editor_stack, editor, vim, qtbot = vim_bot
editor.stdkey_backspace()
editor.go_to_line(3)
cmd_line = vim.get_focus_widget()
qtbot.keyClicks(cmd_line, ':1')
qtbot.keyPress(cmd_line, Qt.Key_Return)
line, _ = editor.get_cursor_line_column()
assert line == 0
示例10: eventFilter
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def eventFilter(self, object, event):
if event.type() == QEvent.KeyPress:
if event.key() == Qt.Key_Space or event.key() == Qt.Key_Return:
self.toggle_selected_columns()
return True
if event.key() == Qt.Key_Delete:
self.delete_selected()
return True
return False
示例11: keyPressEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def keyPressEvent(self, event):
"""On key press lose focus of the lineEdits.
Parameters
----------
event : qtpy.QtCore.QEvent
Event from the Qt context.
"""
# we override the parent keyPressEvent so that hitting enter does not
# hide the window... but we do want to lose focus on the lineEdits
if event.key() in (Qt.Key_Return, Qt.Key_Enter):
self.slider.setFocus()
return
super().keyPressEvent(event)
示例12: keyPressEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def keyPressEvent(self, event: QKeyEvent):
"""Accept current color on enter, cancel on escape.
Parameters
----------
event : QKeyEvent
The keypress event that triggered this method.
"""
if event.key() in (Qt.Key_Return, Qt.Key_Enter):
return self.color_dialog.accept()
if event.key() == Qt.Key_Escape:
return self.color_dialog.reject()
self.color_dialog.keyPressEvent(event)
示例13: keyPressEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def keyPressEvent(self, event):
"""Close window on return, else pass event through to super class.
Parameters
----------
event : qtpy.QtCore.QEvent
Event from the Qt context.
"""
if event.key() in (Qt.Key_Return, Qt.Key_Enter):
return self.close()
super().keyPressEvent(event)
示例14: key_pressed_handler
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def key_pressed_handler(self, event):
intercepted = False
key = event.key()
if key == Qt.Key_Tab:
intercepted = self.handle_tab_key(event)
elif key in (Qt.Key_Return, Qt.Key_Enter, Qt.Key_Space):
intercepted = self.handle_complete_key(event)
elif key == Qt.Key_Escape:
intercepted = self.hide_completion_suggestions()
self._last_key = key
self.update_completion(key)
return intercepted
示例15: keyPressEvent
# 需要导入模块: from qtpy.QtCore import Qt [as 别名]
# 或者: from qtpy.QtCore.Qt import Key_Return [as 别名]
def keyPressEvent(self, event):
"""
Override Qt method.
"""
index = self.currentIndex()
key = event.key()
if key in [Qt.Key_Enter, Qt.Key_Return]:
# self.action_pressed(index)
self.setCurrentIndex(self.proxy_model.index(index.row(),
const.COL_ACTION))
self.pressed_here = True
elif key in [Qt.Key_Tab]:
new_row = index.row() + 1
if not self.proxy_model or new_row == self.proxy_model.rowCount():
self.sig_next_focus.emit()
else:
new_index = self.proxy_model.index(new_row, 0)
self.setCurrentIndex(new_index)
elif key in [Qt.Key_Backtab]:
new_row = index.row() - 1
if new_row < 0:
self.sig_previous_focus.emit()
else:
new_index = self.proxy_model.index(new_row, 0)
self.setCurrentIndex(new_index)
else:
QTableView.keyPressEvent(self, event)
self.update_visible_rows()