本文整理汇总了Python中PyQt5.QtCore.Qt.Key_Backspace方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.Key_Backspace方法的具体用法?Python Qt.Key_Backspace怎么用?Python Qt.Key_Backspace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.Key_Backspace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def keyPressEvent(self, e: QKeyEvent) -> None:
"""Override keyPressEvent to ignore Return key presses.
If this widget is focused, we are in passthrough key mode, and
Enter/Shift+Enter/etc. will cause QLineEdit to think it's finished
without command_accept to be called.
"""
text = self.text()
if text in modeparsers.STARTCHARS and e.key() == Qt.Key_Backspace:
e.accept()
modeman.leave(self._win_id, usertypes.KeyMode.command,
'prefix deleted')
return
if e.key() == Qt.Key_Return:
e.ignore()
return
else:
super().keyPressEvent(e)
示例2: text
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def text(self) -> str:
"""Get the text which would be displayed when pressing this key."""
control = {
Qt.Key_Space: ' ',
Qt.Key_Tab: '\t',
Qt.Key_Backspace: '\b',
Qt.Key_Return: '\r',
Qt.Key_Enter: '\r',
Qt.Key_Escape: '\x1b',
}
if self.key in control:
return control[self.key]
elif not _is_printable(self.key):
return ''
text = QKeySequence(self.key).toString()
if not self.modifiers & Qt.ShiftModifier: # type: ignore[operator]
text = text.lower()
return text
示例3: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def keyPressEvent(self, event):
key = event.key()
if key in (Qt.Key_Backspace, Qt.Key_Delete):
view = self.current_view()
selected = view.selectedIndexes() if view else None
if selected:
view.confirm_stop_syncing(view.get_selected_folders())
if key == Qt.Key_Escape:
view = self.current_view()
selected = view.selectedIndexes() if view else None
if selected:
for index in selected:
view.selectionModel().select(
index, QItemSelectionModel.Deselect
)
elif self.gui.systray.isSystemTrayAvailable():
self.hide()
示例4: test_position
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def test_position(self, qtbot, cmd_edit):
"""Test cursor position based on the prompt."""
qtbot.keyClicks(cmd_edit, ':hello')
assert cmd_edit.text() == ':hello'
assert cmd_edit.cursorPosition() == len(':hello')
cmd_edit.home(True)
assert cmd_edit.cursorPosition() == len(':')
qtbot.keyClick(cmd_edit, Qt.Key_Delete)
assert cmd_edit.text() == ':'
qtbot.keyClick(cmd_edit, Qt.Key_Backspace)
assert cmd_edit.text() == ':'
qtbot.keyClicks(cmd_edit, 'hey again')
assert cmd_edit.text() == ':hey again'
示例5: test_backspacing_path
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def test_backspacing_path(self, qtbot, tmpdir, get_prompt):
"""When we start deleting a path we want to see the subdir."""
testdir = tmpdir / 'test'
for directory in ['bar', 'foo']:
(testdir / directory).ensure(dir=True)
prompt = get_prompt(str(testdir / 'foo') + os.sep)
# Deleting /f[oo/]
with qtbot.wait_signal(prompt._file_model.directoryLoaded):
for _ in range(3):
qtbot.keyPress(prompt._lineedit, Qt.Key_Backspace)
# foo should get completed from f
prompt.item_focus('next')
assert prompt._lineedit.text() == str(testdir / 'foo')
# Deleting /[foo]
for _ in range(3):
qtbot.keyPress(prompt._lineedit, Qt.Key_Backspace)
# We should now show / again, so tabbing twice gives us .. -> bar
prompt.item_focus('next')
prompt.item_focus('next')
assert prompt._lineedit.text() == str(testdir / 'bar')
示例6: _handle_filter_key
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def _handle_filter_key(self, e: QKeyEvent) -> QKeySequence.SequenceMatch:
"""Handle keys for string filtering."""
log.keyboard.debug("Got filter key 0x{:x} text {}".format(
e.key(), e.text()))
if e.key() == Qt.Key_Backspace:
log.keyboard.debug("Got backspace, mode {}, filtertext '{}', "
"sequence '{}'".format(self._last_press,
self._filtertext,
self._sequence))
if self._last_press != LastPress.keystring and self._filtertext:
self._filtertext = self._filtertext[:-1]
self._hintmanager.filter_hints(self._filtertext)
return QKeySequence.ExactMatch
elif self._last_press == LastPress.keystring and self._sequence:
self._sequence = self._sequence[:-1]
self.keystring_updated.emit(str(self._sequence))
if not self._sequence and self._filtertext:
# Switch back to hint filtering mode (this can happen only
# in numeric mode after the number has been deleted).
self._hintmanager.filter_hints(self._filtertext)
self._last_press = LastPress.filtertext
return QKeySequence.ExactMatch
else:
return QKeySequence.NoMatch
elif self._hintmanager.current_mode() != 'number':
return QKeySequence.NoMatch
elif not e.text():
return QKeySequence.NoMatch
else:
self._filtertext += e.text()
self._hintmanager.filter_hints(self._filtertext)
self._last_press = LastPress.filtertext
return QKeySequence.ExactMatch
示例7: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def keyPressEvent(self, e):
if self.mode == 'text':
if e.key() == Qt.Key_Backspace:
self.current_text = self.current_text[:-1]
else:
self.current_text = self.current_text + e.text()
示例8: keyReleaseEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def keyReleaseEvent(self, e):
if e.key() == Qt.Key_Return:
try:
self.updateAutoComplete(self.parent.fileName)
except AttributeError as E:
print(E, "on line 210 in TextEditor.py")
if e.key() == Qt.Key_Backspace:
pass
示例9: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def keyPressEvent(self, event):
chk_event = self.parent.notes.action['new_event'].isChecked()
chk_book = self.parent.notes.action['new_bookmark'].isChecked()
if not ((chk_event or chk_book) and self.event_sel):
return
annot = self.event_sel
highlight = self.highlight
annot_start = annot.marker.x()
annot_end = annot_start + annot.marker.width()
if type(event) == QKeyEvent and (
event.key() == Qt.Key_Delete or event.key() == Qt.Key_Backspace):
if chk_event:
self.parent.notes.remove_event(time=(annot_start, annot_end))
elif chk_book:
self.parent.notes.remove_bookmark(
time=(annot_start, annot_end))
self.scene.removeItem(highlight)
msg = 'Deleted event from {} to {}'.format(annot_start, annot_end)
self.parent.statusBar().showMessage(msg)
self.event_sel = None
self.highlight = None
self.parent.notes.idx_eventtype.setCurrentText(self.current_etype)
self.current_etype = None
self.current_event = None
self.display_annotations
示例10: textChanged
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def textChanged(self, e): # QKeyEvent(QEvent.KeyPress, Qt.Key_Enter, Qt.NoModifier)
# if (32<e.key()<96 or 123<e.key()<126 or 0x1000001<e.key()<0x1000005 or e.key==Qt.Key_Delete):
# 大键盘为Ret小键盘为Enter
if (e.key() in (Qt.Key_Return, Qt.Key_Enter, Qt.Key_Semicolon, Qt.Key_BraceRight, Qt.Key_Up, Qt.Key_Down,
Qt.Key_Left, Qt.Key_Right, Qt.Key_Tab, Qt.Key_Delete, Qt.Key_Backspace)):
self.renderStyle()
self.loadColorPanel()
self.actions["undo"].setEnabled(self.editor.isUndoAvailable())
self.actions["redo"].setEnabled(self.editor.isRedoAvailable())
示例11: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def keyPressEvent(self, event): # pylint: disable=invalid-name
key = event.key()
if key == Qt.Key_Backspace or key == Qt.Key_Escape:
self._back()
return super().keyPressEvent(event)
示例12: eventFilter
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def eventFilter(self, sender, event):
if event.type() == QEvent.ChildRemoved:
self.internalMove.emit()
elif event.type() == QEvent.KeyPress and event.key() in (Qt.Key_Delete, Qt.Key_Backspace)\
and self.currentItem() is not None:
item = self.currentRow()
item_name = self.currentItem().text()
self.active_element_text = item_name
self.takeItem(item)
self.deleteElement.emit()
return False
示例13: test_MicroPythonREPLPane_keyPressEvent_backspace
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def test_MicroPythonREPLPane_keyPressEvent_backspace(qtapp):
"""
Ensure backspaces in the REPL are handled correctly.
"""
mock_serial = mock.MagicMock()
rp = mu.interface.panes.MicroPythonREPLPane(mock_serial)
data = mock.MagicMock
data.key = mock.MagicMock(return_value=Qt.Key_Backspace)
data.text = mock.MagicMock(return_value="\b")
data.modifiers = mock.MagicMock(return_value=None)
rp.keyPressEvent(data)
mock_serial.write.assert_called_once_with(b"\b")
示例14: test_PythonProcessPane_parse_input_backspace
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def test_PythonProcessPane_parse_input_backspace(qtapp):
"""
Backspace call causes a backspace from the character at the cursor
position.
"""
ppp = mu.interface.panes.PythonProcessPane()
ppp.backspace = mock.MagicMock()
key = Qt.Key_Backspace
text = "\b"
modifiers = None
ppp.parse_input(key, text, modifiers)
ppp.backspace.assert_called_once_with()
示例15: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Backspace [as 别名]
def keyPressEvent(self, event):
''' Handle keyboard input for bluesky. '''
# Enter-key: enter command
if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return:
if self.command_line:
# emit a signal with the command for the simulation thread
self.stack(self.command_line)
# Clear any shape command preview on the radar display
# self.radarwidget.previewpoly(None)
return
newcmd = self.command_line
cursorpos = None
if event.key() >= Qt.Key_Space and event.key() <= Qt.Key_AsciiTilde:
pos = self.lineEdit.cursor_pos()
newcmd = newcmd[:pos] + event.text() + newcmd[pos:]
# Update the cursor position with the length of the added text
cursorpos = pos + len(event.text())
elif event.key() == Qt.Key_Backspace:
pos = self.lineEdit.cursor_pos()
newcmd = newcmd[:pos - 1] + newcmd[pos:]
cursorpos = pos - 1
elif event.key() == Qt.Key_Tab:
if newcmd:
newcmd, displaytext = autocomplete.complete(newcmd)
if displaytext:
self.echo(displaytext)
elif not event.modifiers() & (Qt.ControlModifier | Qt.ShiftModifier |
Qt.AltModifier | Qt.MetaModifier):
if event.key() == Qt.Key_Up:
if self.history_pos == 0:
self.command_mem = newcmd
if len(self.command_history) >= self.history_pos + 1:
self.history_pos += 1
newcmd = self.command_history[-self.history_pos]
elif event.key() == Qt.Key_Down:
if self.history_pos > 0:
self.history_pos -= 1
if self.history_pos == 0:
newcmd = self.command_mem
else:
newcmd = self.command_history[-self.history_pos]
elif event.key() == Qt.Key_Left:
self.lineEdit.cursor_left()
elif event.key() == Qt.Key_Right:
self.lineEdit.cursor_right()
else:
# Remaining keys are things like sole modifier keys, and function keys
super(Console, self).keyPressEvent(event)
else:
event.ignore()
return
# Final processing of the command line
self.set_cmdline(newcmd, cursorpos)