本文整理汇总了Python中PyQt5.QtCore.Qt.Key_Delete方法的典型用法代码示例。如果您正苦于以下问题:Python Qt.Key_Delete方法的具体用法?Python Qt.Key_Delete怎么用?Python Qt.Key_Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.Qt
的用法示例。
在下文中一共展示了Qt.Key_Delete方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [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()
示例2: test_position
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [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'
示例3: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [as 别名]
def keyPressEvent(self, event):
if event.key() == Qt.Key_Delete:
self.delete_files()
示例4: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [as 别名]
def keyPressEvent(self, e):
if e.key() == Qt.Key_Delete: # delete
self.slot_btn_deleteSelect()
示例5: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [as 别名]
def keyPressEvent(self, event):
key = event.key()
if key == Qt.Key_Delete:
try:
self.fileObject = self.selectedIndexes()[0]
fileName = self.model.filePath(self.fileObject)
self.confirmation.run("Are you sure you want to delete ", str(fileName))
except IndexError:
print("No file selected")
示例6: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [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
示例7: textChanged
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [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())
示例8: keyReleaseEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [as 别名]
def keyReleaseEvent(self, event):
if event.key() == Qt.Key_Delete:
item = self.scene().focusItem()
self.scene().removeArea(item)
#elif event.key() == Qt.Key_Escape:
# self.first = True
QGraphicsView.keyReleaseEvent(self, event)
示例9: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [as 别名]
def keyPressEvent(self, event: QKeyEvent):
if event.key() == Qt.Key_Delete:
selected = self.selectionModel().selection()
""":type: QtGui.QItemSelection """
if selected.isEmpty():
return
min_row = numpy.min([rng.top() for rng in selected])
max_row = numpy.max([rng.bottom() for rng in selected])
self.deletion_wanted.emit(min_row, max_row)
else:
super().keyPressEvent(event)
示例10: keyPressEvent
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [as 别名]
def keyPressEvent(self, event: QKeyEvent):
if event.key() == Qt.Key_Delete:
self.deletion_wanted.emit()
event.ignore()
else:
super().keyPressEvent(event)
示例11: eventFilter
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [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
示例12: test_MicroPythonREPLPane_keyPressEvent_delete
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [as 别名]
def test_MicroPythonREPLPane_keyPressEvent_delete(qtapp):
"""
Ensure delete 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_Delete)
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"\x1B[\x33\x7E")
示例13: test_PythonProcessPane_parse_input_delete
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [as 别名]
def test_PythonProcessPane_parse_input_delete(qtapp):
"""
Delete deletes the character to the right of the cursor position.
"""
ppp = mu.interface.panes.PythonProcessPane()
ppp.delete = mock.MagicMock()
key = Qt.Key_Delete
text = "\b"
modifiers = None
ppp.parse_input(key, text, modifiers)
ppp.delete.assert_called_once_with()
示例14: test_generator_label
# 需要导入模块: from PyQt5.QtCore import Qt [as 别名]
# 或者: from PyQt5.QtCore.Qt import Key_Delete [as 别名]
def test_generator_label(self):
labels = self.cframe.proto_analyzer.protocol_labels
self.assertEqual(len(labels), 2)
# Open Protocol in Generator
self.form.ui.tabWidget.setCurrentIndex(2)
item = self.gframe.tree_model.rootItem.children[0].children[0]
index = self.gframe.tree_model.createIndex(0, 0, item)
rect = self.gframe.ui.treeProtocols.visualRect(index)
self.assertEqual(len(self.gframe.ui.treeProtocols.selectedIndexes()), 0)
QTest.mousePress(self.gframe.ui.treeProtocols.viewport(), Qt.LeftButton, pos=rect.center())
self.assertEqual(self.gframe.ui.treeProtocols.selectedIndexes()[0], index)
mimedata = self.gframe.tree_model.mimeData(self.gframe.ui.treeProtocols.selectedIndexes())
self.gframe.table_model.dropMimeData(mimedata, 1, -1, -1, self.gframe.table_model.createIndex(0, 0))
self.assertEqual(self.gframe.table_model.row_count, 3)
# Check Label in Generator
labels = self.gframe.table_model.protocol.protocol_labels
self.assertEqual(len(labels), 2)
# Fuzz Label
lbl = copy.deepcopy(self.gframe.table_model.protocol.messages[0].message_type[1])
self.gframe.table_model.protocol.messages[0].message_type[1] = lbl
lbl.fuzz_values.append("1")
lbl.add_fuzz_value()
lbl.add_fuzz_value()
lbl.add_fuzz_value()
lbl.add_fuzz_value()
lbl.fuzz_me = Qt.Checked
self.assertEqual(len(lbl.fuzz_values), 5)
self.gframe.refresh_label_list()
self.gframe.refresh_table()
self.gframe.ui.btnFuzz.setEnabled(True)
self.gframe.ui.btnFuzz.click()
self.assertTrue(lbl.active_fuzzing)
self.assertIn(lbl, self.gframe.table_model.protocol.messages[0].message_type)
self.assertEqual(self.gframe.table_model.row_count, 4 + 3)
# Check if Background for fuzzed labels is drawn correctly
self.__check_background_is_drawn(lbl, 43, 43)
# Delete a line
old_row_count = self.gframe.table_model.row_count
self.gframe.ui.tableMessages.selectRow(2)
QTest.keyClick(self.gframe.ui.tableMessages, Qt.Key_Delete)
self.assertEqual(self.gframe.table_model.row_count, old_row_count - 1)
self.__check_background_is_drawn(lbl, 43, 43)
# Remove everything
for i in range(old_row_count):
self.gframe.ui.tableMessages.selectRow(0)
QTest.keyClick(self.gframe.ui.tableMessages, Qt.Key_Delete)
self.assertEqual(self.gframe.table_model.row_count, 0)