我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用PyQt5.QtCore.Qt.Key_I()。
def keyPressEvent(self, event): key_handlers = { Qt.Key_1: self.select_number(1), Qt.Key_2: self.select_number(2), Qt.Key_3: self.select_number(3), Qt.Key_4: self.select_number(4), Qt.Key_5: self.select_number(5), Qt.Key_6: self.select_number(6), Qt.Key_7: self.select_number(7), Qt.Key_8: self.select_number(8), Qt.Key_9: self.select_number(9), Qt.Key_0: self.select_number(0), Qt.Key_A: self.start_edit(self.goals.add, 'Add new goal'), Qt.Key_C: self.with_refresh(self.goals.toggle_close), Qt.Key_D: self.with_refresh(self.goals.delete), Qt.Key_I: self.start_edit(self.goals.insert, 'Insert new goal'), Qt.Key_L: self.with_refresh(self.goals.toggle_link), Qt.Key_Q: self.quit_app.emit, Qt.Key_R: self.start_edit(self.goals.rename, 'Rename goal'), Qt.Key_S: self.with_refresh(self.goals.swap_goals), Qt.Key_V: self.toggle_view, Qt.Key_Z: self.toggle_zoom, Qt.Key_Escape: self.cancel_edit, Qt.Key_Space: self.with_refresh(self.goals.hold_select), } if event.key() in key_handlers: key_handlers[event.key()]() else: super().keyPressEvent(event)
def set_up_keyboard_keys(self): row_1 = [Qt.Key_Q, Qt.Key_W, Qt.Key_E, Qt.Key_R, Qt.Key_T, Qt.Key_Y, Qt.Key_Y, Qt.Key_I, Qt.Key_O, Qt.Key_P, Qt.Key_Backspace] row_2 = [Qt.Key_A, Qt.Key_S, Qt.Key_D, Qt.Key_F, Qt.Key_G, Qt.Key_H, Qt.Key_J, Qt.Key_K, Qt.Key_L, Qt.Key_Ccedilla, Qt.Key_Return] row_3 = [Qt.Key_Aring, Qt.Key_Z, Qt.Key_X, Qt.Key_C, Qt.Key_V, Qt.Key_B, Qt.Key_N, Qt.Key_M, Qt.Key_Comma, Qt.Key_Period, Qt.Key_Question, Qt.Key_Aring] row_4 = [Qt.Key_Aring, Qt.Key_Space, Qt.Key_Left, Qt.Key_Right, Qt.Key_Aring] self.keyboard_keys = [row_1, row_2, row_3, row_4]