Python源码示例:PyQt5.QtCore.Qt.Key_End()
示例1
def keyPressEvent(self, event):
"""Reimplemented."""
# Override the default QComboBox behavior
if event.key() == Qt.Key_Down and event.modifiers() & Qt.AltModifier:
self.showPopup()
return
ignored = {Qt.Key_Up, Qt.Key_Down,
Qt.Key_PageDown, Qt.Key_PageUp,
Qt.Key_Home, Qt.Key_End}
if event.key() in ignored:
event.ignore()
return
super(CheckComboBox, self).keyPressEvent(event)
示例2
def bottom(self):
self._key_press(Qt.Key_End)
示例3
def test_MicroPythonREPLPane_keyPressEvent_end(qtapp):
"""
Ensure end key in the REPL is handled correctly.
"""
mock_serial = mock.MagicMock()
rp = mu.interface.panes.MicroPythonREPLPane(mock_serial)
data = mock.MagicMock
data.key = mock.MagicMock(return_value=Qt.Key_End)
data.text = mock.MagicMock(return_value="1b")
data.modifiers = mock.MagicMock(return_value=None)
rp.keyPressEvent(data)
mock_serial.write.assert_called_once_with(b"\x1B[F")
示例4
def test_PythonProcessPane_parse_input_end(qtapp):
"""
End moves cursor to the end of the input line.
"""
ppp = mu.interface.panes.PythonProcessPane()
mock_cursor = mock.MagicMock()
ppp.textCursor = mock.MagicMock(return_value=mock_cursor)
ppp.setTextCursor = mock.MagicMock()
key = Qt.Key_End
text = ""
modifiers = None
ppp.parse_input(key, text, modifiers)
mock_cursor.movePosition.assert_called_once_with(QTextCursor.End)
ppp.setTextCursor.assert_called_once_with(mock_cursor)