本文整理汇总了Python中PyQt5.QtCore.Qt.Key_Tab方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.Key_Tab方法的具体用法?Python Qt.Key_Tab怎么用?Python Qt.Key_Tab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.Key_Tab方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: text
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Tab [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
示例2: textChanged
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Tab [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())
示例3: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Tab [as 别名]
def keyPressEvent(self, event):
tc = self.textCursor()
if event.key() == Qt.Key_Enter or event.key() == Qt.Key_Return or event.key() == Qt.Key_Tab:
if self.completer and self.completer.popup().isVisible():
self.completer.insertText.emit(self.completer.getSelected())
self.completer.setCompletionMode(QCompleter.PopupCompletion)
event.ignore()
return
super().keyPressEvent(event)
tc.select(QTextCursor.WordUnderCursor)
cr = self.cursorRect()
if self.completer:
if tc.selectedText():
self.completer.setCompletionPrefix(tc.selectedText())
popup = self.completer.popup()
#popup.setCurrentIndex(self.completer.completionModel().index(0, 0))
cr.setWidth(
self.completer.popup().sizeHintForColumn(0) +
self.completer.popup().verticalScrollBar().sizeHint().width())
self.completer.complete(cr)
else:
self.completer.popup().hide()
示例4: append_event
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Tab [as 别名]
def append_event(self, ev: QKeyEvent) -> 'KeySequence':
"""Create a new KeySequence object with the given QKeyEvent added."""
key = Qt.Key(ev.key())
_assert_plain_key(key)
_assert_plain_modifier(ev.modifiers())
key = _remap_unicode(key, ev.text())
modifiers = int(ev.modifiers())
if key == _NIL_KEY:
raise KeyParseError(None, "Got nil key!")
# We always remove Qt.GroupSwitchModifier because QKeySequence has no
# way to mention that in a binding anyways...
modifiers &= ~Qt.GroupSwitchModifier
# We change Qt.Key_Backtab to Key_Tab here because nobody would
# configure "Shift-Backtab" in their config.
if modifiers & Qt.ShiftModifier and key == Qt.Key_Backtab:
key = Qt.Key_Tab
# We don't care about a shift modifier with symbols (Shift-: should
# match a : binding even though we typed it with a shift on an
# US-keyboard)
#
# However, we *do* care about Shift being involved if we got an
# upper-case letter, as Shift-A should match a Shift-A binding, but not
# an "a" binding.
#
# In addition, Shift also *is* relevant when other modifiers are
# involved. Shift-Ctrl-X should not be equivalent to Ctrl-X.
if (modifiers == Qt.ShiftModifier and
_is_printable(key) and
not ev.text().isupper()):
modifiers = Qt.KeyboardModifiers() # type: ignore[assignment]
# On macOS, swap Ctrl and Meta back
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-51293
if utils.is_mac:
if modifiers & Qt.ControlModifier and modifiers & Qt.MetaModifier:
pass
elif modifiers & Qt.ControlModifier:
modifiers &= ~Qt.ControlModifier
modifiers |= Qt.MetaModifier
elif modifiers & Qt.MetaModifier:
modifiers &= ~Qt.MetaModifier
modifiers |= Qt.ControlModifier
keys = list(self._iter_keys())
keys.append(key | int(modifiers))
return self.__class__(*keys)
示例5: eventFilter
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Tab [as 别名]
def eventFilter(self, target, event):
def match(s1, s2):
for x in s2:
if s1.matches(x) == QKeySequence.ExactMatch:
return True
return False
if target == self.inputTextBox:
if isinstance(event, QKeyEvent):
if event.type() == QKeyEvent.KeyPress:
event_sequence = QtHelper.key_event_sequence(event)
if match(event_sequence, Settings().new_line_key):
return False
if match(event_sequence, Settings().send_key):
self.send_input()
return True
if event.key() == Qt.Key_Tab:
self.inputTextBox.insertPlainText(" "*Settings().terminal_tab_spaces)
return True
if event.key() == Qt.Key_Up and (event.modifiers() & Qt.ControlModifier):
if self._input_history_index > 0:
self._input_history_index -= 1
self.inputTextBox.clear()
self.inputTextBox.setPlainText(self.terminal.input(self._input_history_index))
if event.key() == Qt.Key_Down and (event.modifiers() & Qt.ControlModifier):
if self._input_history_index < self.terminal.last_input_idx():
self._input_history_index += 1
self.inputTextBox.clear()
self.inputTextBox.setPlainText(self.terminal.input(self._input_history_index))
elif target == self.outputTextEdit:
if isinstance(event, QKeyEvent):
if event.type() == QEvent.KeyPress:
if event.key() == Qt.Key_Up:
self.connection.send_bytes(b"\x1b[A")
if event.key() == Qt.Key_Down:
self.connection.send_bytes(b"\x1b[B")
else:
t = event.text()
if t:
self.connection.send_character(t)
return True
elif target == self.outputTextEdit.verticalScrollBar():
if isinstance(event, QHideEvent):
return True
return False
示例6: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Tab [as 别名]
def keyPressEvent(self, event):
if (
self.completer
and self.completer.popup()
and self.completer.popup().isVisible()
):
if event.key() in (
Qt.Key_Enter,
Qt.Key_Return,
Qt.Key_Escape,
Qt.Key_Tab,
Qt.Key_Backtab,
):
event.ignore()
return
isShortcut = event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_B
if not self.completer or not isShortcut:
QPlainTextEdit.keyPressEvent(self.editor, event)
completionPrefix = self.textUnderCursor()
if not isShortcut:
if self.completer.popup():
self.completer.popup().hide()
return
self.completer.setCompletionPrefix(completionPrefix)
popup = self.completer.popup()
popup.setFont(self.font)
popup.setCurrentIndex(self.completer.completionModel().index(0, 0))
cr = self.editor.cursorRect()
cr.translate(QPoint(10, 10))
cr.setWidth(
self.completer.popup().sizeHintForColumn(0)
+ self.completer.popup().verticalScrollBar().sizeHint().width()
)
self.completer.complete(cr)
示例7: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Tab [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)