Python源码示例:PyQt5.QtCore.Qt.CTRL

示例1
def __init__(self, parent=None):
        super().__init__(parent)

        self.context_menu_pos = None  # type: QPoint

        self.copy_action = QAction("Copy selection", self)
        self.copy_action.setShortcut(QKeySequence.Copy)
        self.copy_action.setIcon(QIcon.fromTheme("edit-copy"))
        self.copy_action.triggered.connect(self.on_copy_action_triggered)

        self.use_header_colors = False

        self.original_font_size = self.font().pointSize()
        self.original_header_font_sizes = {"vertical": self.verticalHeader().font().pointSize(),
                                           "horizontal": self.horizontalHeader().font().pointSize()}

        self.zoom_in_action = QAction(self.tr("Zoom in"), self)
        self.zoom_in_action.setShortcut(QKeySequence.ZoomIn)
        self.zoom_in_action.triggered.connect(self.on_zoom_in_action_triggered)
        self.zoom_in_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        self.zoom_in_action.setIcon(QIcon.fromTheme("zoom-in"))
        self.addAction(self.zoom_in_action)

        self.zoom_out_action = QAction(self.tr("Zoom out"), self)
        self.zoom_out_action.setShortcut(QKeySequence.ZoomOut)
        self.zoom_out_action.triggered.connect(self.on_zoom_out_action_triggered)
        self.zoom_out_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        self.zoom_out_action.setIcon(QIcon.fromTheme("zoom-out"))
        self.addAction(self.zoom_out_action)

        self.zoom_original_action = QAction(self.tr("Zoom original"), self)
        self.zoom_original_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_0))
        self.zoom_original_action.triggered.connect(self.on_zoom_original_action_triggered)
        self.zoom_original_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        self.zoom_original_action.setIcon(QIcon.fromTheme("zoom-original"))
        self.addAction(self.zoom_original_action)

        self.horizontalHeader().setMinimumSectionSize(0) 
示例2
def left(self):
        self.widget.switch_page(right=False)
        
        
        
    #def keyPressEvent(self, event):
        #这里event.key()显示的是按键的编码
        #print("按下:" + str(event.key()))
        # 举例,这里Qt.Key_A注意虽然字母大写,但按键事件对大小写不敏感
        #if (event.key() == Qt.Key_Left):
        #    self.widget.switch_page(right=False)
        #elif (event.key() == Qt.Key_Right):
        #    self.widget.switch_page(right=True)
        #elif (event.modifiers() == Qt.CTRL and event.key() == Qt.Key_Plus):
        #    self.widget.zoom_book(plus=True)
        #elif (event.modifiers() == Qt.CTRL and event.key() == Qt.Key_Minus):
        #    self.widget.zoom_book(plus=False) 
示例3
def key_event_sequence(event):
        val = event.key()
        mod = event.modifiers()
        if mod & Qt.ShiftModifier:
            val += Qt.SHIFT
        if mod & Qt.ControlModifier:
            val += Qt.CTRL
        if mod & Qt.AltModifier:
            val += Qt.ALT
        if mod & Qt.MetaModifier:
            val += Qt.META
        return QKeySequence(val) 
示例4
def onKeyPressEvent(self, e):
        if not e.isAutoRepeat():
            keys = e.key()
            modifiers = e.modifiers()

            if modifiers & Qt.ShiftModifier:
                keys += Qt.SHIFT
            if modifiers & Qt.ControlModifier:
                keys += Qt.CTRL
            if modifiers & Qt.AltModifier:
                keys += Qt.ALT
            if modifiers & Qt.MetaModifier:
                keys += Qt.META

            if QKeySequence(keys) in self._go_key_sequence:
                self.go()
            elif e.key() == Qt.Key_Space:
                if qApp.keyboardModifiers() == Qt.ShiftModifier:
                    cue = self.current_cue()
                    if cue is not None:
                        self.edit_cue(cue)
                elif qApp.keyboardModifiers() == Qt.ControlModifier:
                    item = self.current_item()
                    if item is not None:
                        item.selected = not item.selected
            else:
                self.key_pressed.emit(e)

        e.accept() 
示例5
def __init__(self, parent=None):
        super().__init__(parent)

        self.context_menu_position = None  # type: QPoint
        self.scene_type = 0

        self.auto_fit_on_resize_is_blocked = False

        self.zoom_in_action = QAction(self.tr("Zoom in"), self)
        self.zoom_in_action.setShortcut(QKeySequence.ZoomIn)
        self.zoom_in_action.triggered.connect(self.on_zoom_in_action_triggered)
        self.zoom_in_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        self.zoom_in_action.setIcon(QIcon.fromTheme("zoom-in"))
        self.addAction(self.zoom_in_action)

        self.zoom_out_action = QAction(self.tr("Zoom out"), self)
        self.zoom_out_action.setShortcut(QKeySequence.ZoomOut)
        self.zoom_out_action.triggered.connect(self.on_zoom_out_action_triggered)
        self.zoom_out_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        self.zoom_out_action.setIcon(QIcon.fromTheme("zoom-out"))
        self.addAction(self.zoom_out_action)

        self.zoom_original_action = QAction(self.tr("Zoom original"), self)
        self.zoom_original_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_0))
        self.zoom_original_action.triggered.connect(self.on_zoom_original_action_triggered)
        self.zoom_original_action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
        self.zoom_original_action.setIcon(QIcon.fromTheme("zoom-original"))
        self.addAction(self.zoom_original_action)

        self.redraw_timer = QTimer(self)
        self.redraw_timer.setSingleShot(True)
        self.redraw_timer.timeout.connect(self.redraw_view)

        self.zoomed.connect(self.on_signal_zoomed)

        self.scene_x_zoom_stretch = 1 
示例6
def __init__(self, parent=None, plugins=None, fullscreen=False):
        super(DeenGui, self).__init__(parent)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.plugins = plugins
        self.widgets = []
        self.ui.actionLoad_from_file.triggered.connect(self.load_from_file)
        self.ui.actionQuit.triggered.connect(QApplication.quit)
        self.ui.actionAbout.triggered.connect(self.show_about)
        self.ui.actionStatus_console.triggered.connect(self.show_status_console)
        self.ui.actionTop_to_bottom.triggered.connect(self.set_widget_direction_toptobottom)
        self.ui.actionLeft_to_right.triggered.connect(self.set_widget_direction_lefttoright)
        # Set default direction
        self.set_widget_direction_toptobottom()
        self.ui.actionCopy_to_clipboard.triggered.connect(self.copy_content_to_clipboard)
        self.ui.actionSave_content_to_file.triggered.connect(self.save_widget_content_to_file)
        self.ui.actionSearch.triggered.connect(self.toggle_search_box_visibility)
        self.widgets.append(DeenEncoderWidget(self))
        for widget in self.widgets:
            self.ui.encoder_widget_layout.addWidget(widget)
        self.load_from_file_dialog = QFileDialog(self)
        self.setWindowTitle('deen')
        self.log = DeenLogger(self)
        self.widgets[0].set_field_focus()
        # Add action fuzzy search
        self.fuzzy_search_ui = FuzzySearchUi(self)
        self.fuzzy_search_action_shortcut = QShortcut(QKeySequence(Qt.CTRL | Qt.Key_R), self)
        self.fuzzy_search_action_shortcut.activated.connect(self.fuzzy_search_action)
        self.clear_current_widget_shortcut = QShortcut(QKeySequence(Qt.CTRL | Qt.Key_Q), self)
        self.clear_current_widget_shortcut.activated.connect(self.clear_current_widget)
        self.hide_search_box_shortcut = QShortcut(QKeySequence(Qt.CTRL | Qt.Key_F), self)
        self.hide_search_box_shortcut.activated.connect(self.toggle_search_box_visibility)
        self.next_encoder_widget_shortcut = QShortcut(QKeySequence(Qt.ALT | Qt.Key_Right), self)
        self.next_encoder_widget_shortcut.activated.connect(self.toggle_next_encoder_focus)
        self.prev_encoder_widget_shortcut = QShortcut(QKeySequence(Qt.ALT | Qt.Key_Left), self)
        self.prev_encoder_widget_shortcut.activated.connect(self.toggle_prev_encoder_focus)
        if fullscreen:
            self.showMaximized()
        self.show()