Python PyQt5.QtCore.Qt 模块,CTRL 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用PyQt5.QtCore.Qt.CTRL

项目:mpvQC    作者:Frechdachs    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        pressedkey = event.key()
        if ((pressedkey == Qt.Key_Up or pressedkey == Qt.Key_Down)
                and int(app.keyboardModifiers()) == Qt.NoModifier):
            super(CommentListView, self).keyPressEvent(event)
        elif pressedkey == Qt.Key_Delete:
            deleteSelection()
            event.accept()
        elif pressedkey == Qt.Key_Enter or pressedkey == Qt.Key_Return:
            editSelection()
            event.accept()
        elif pressedkey == Qt.Key_C and int(app.keyboardModifiers()) == Qt.CTRL:
            copySelection()
            event.accept()
        else:
            event.ignore()
项目:uPyLoader    作者:BetaRavener    | 项目源码 | 文件源码
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)
项目:QtPropertyBrowserV2.6-for-pyqt5    作者:theall    | 项目源码 | 文件源码
def translateModifiers(self, state, text):
        result = 0
        if ((state & Qt.ShiftModifier) and (len(text) == 0 or not text[0].isprintable() or text[0].isalpha() or text[0].isspace())):
            result |= Qt.SHIFT
        if (state & Qt.ControlModifier):
            result |= Qt.CTRL
        if (state & Qt.MetaModifier):
            result |= Qt.META
        if (state & Qt.AltModifier):
            result |= Qt.ALT
        return result
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def init(self):

        self.main_vbox = QVBoxLayout()

        self.my_figure=Figure(figsize=(5,4), dpi=100)
        self.canvas = FigureCanvas(self.my_figure)
        self.canvas.mpl_connect('key_press_event', self.press)
        self.canvas.setFocusPolicy( Qt.ClickFocus )
        self.canvas.setFocus()
        self.canvas.figure.patch.set_facecolor('white')
        #self.canvas.set_size_request(600, 400)
        self.canvas.show()

        self.main_vbox.addWidget(self.canvas)

        #self.canvas.connect('key_press_event', self.on_key_press_event)


        self.setLayout(self.main_vbox)


#   def keyPressEvent(self, event):
#       pritn("oh")
#
#       keyname = ''
#       key = event.key()
#       modifiers = int(event.modifiers())
#       if (Qt.CTRL & modifiers)==modifiers and key==67:
#           self.do_clip()
#           self.canvas.draw()
项目:BannerFactory    作者:xuning0    | 项目源码 | 文件源码
def setup_menu(self):
        menu_bar = self.menuBar()

        file_menu = menu_bar.addMenu('??')

        open_local_action = QAction('????…', self)
        open_local_action.setShortcut(QKeySequence.Open)
        open_local_action.triggered.connect(self.open_local)
        file_menu.addAction(open_local_action)

        # search_image_action = QAction('????…', self)
        # search_image_action.setShortcut(QKeySequence.Find)
        # search_image_action.triggered.connect(self.search_remote_image)
        # file_menu.addAction(search_image_action)

        save_action = QAction('??…', self)
        save_action.setShortcut(QKeySequence.Save)
        save_action.triggered.connect(self.save)
        file_menu.addAction(save_action)
        # ---------------------------------------
        function_menu = menu_bar.addMenu('??')

        preview_action = QAction('??', self)
        preview_action.setShortcut(Qt.CTRL + Qt.Key_P)
        preview_action.triggered.connect(self.preview)
        function_menu.addAction(preview_action)
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def __init__(self, parent=None):
        super().__init__(parent)

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

        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.redraw_timer.setSingleShot(True)
        self.redraw_timer.timeout.connect(self.redraw_view)

        self.zoomed.connect(self.on_signal_zoomed)

        self.scene_y_min = float("nan")  # NaN = AutoDetect
        self.scene_y_max = float("nan")  # NaN = AutoDetect

        self.scene_x_zoom_stretch = 1
项目:qt_style_sheet_inspector    作者:ESSS    | 项目源码 | 文件源码
def __init__(self, parent=None):
        QWidget.__init__(self, parent)
        self.tape = []
        self.tape_pos = -1

        self.style_sheet = None

        self.search_bar = QLineEdit(self)
        self.search_bar.textChanged.connect(self.onSearchTextChanged)

        self.style_text_edit = QTextEdit(self)
        self.style_text_edit.textChanged.connect(self.onStyleTextChanged)
        # To prevent messing with contents when pasted from an IDE, for
        # instance.
        self.style_text_edit.setAcceptRichText(False)

        self.apply_button = QPushButton('Apply', self)
        self.apply_button.clicked.connect(self.onApplyButton)

        layout = QVBoxLayout(self)
        layout.addWidget(self.search_bar)
        layout.addWidget(self.style_text_edit)
        layout.addWidget(self.apply_button)
        self.setLayout(layout)

        next_hit_shortcut = QShortcut(QKeySequence(Qt.Key_F3), self)
        next_hit_shortcut.activated.connect(self.onNextSearchHit)

        search_shortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_F), self)
        search_shortcut.activated.connect(self.onFocusSearchBar)

        apply_shortcut = QShortcut(QKeySequence(Qt.CTRL + Qt.Key_S), self)
        apply_shortcut.activated.connect(self.applyStyleSheet)

        undo_shortcut = QShortcut(
            QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_Z), self)
        undo_shortcut.activated.connect(self.onUndo)

        redo_shortcut = QShortcut(
            QKeySequence(Qt.CTRL + Qt.ALT + Qt.Key_Y), self)
        redo_shortcut.activated.connect(self.onRedo)

        help_shortcut = QShortcut(
            QKeySequence(Qt.Key_F1), self)
        help_shortcut.activated.connect(self.onHelp)

        self.loadStyleSheet()
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def createActions(self):
        self.cell_sumAction = QAction("Sum", self)
        self.cell_sumAction.triggered.connect(self.actionSum)

        self.cell_addAction = QAction("&Add", self)
        self.cell_addAction.setShortcut(Qt.CTRL | Qt.Key_Plus)
        self.cell_addAction.triggered.connect(self.actionAdd)

        self.cell_subAction = QAction("&Subtract", self)
        self.cell_subAction.setShortcut(Qt.CTRL | Qt.Key_Minus)
        self.cell_subAction.triggered.connect(self.actionSubtract)

        self.cell_mulAction = QAction("&Multiply", self)
        self.cell_mulAction.setShortcut(Qt.CTRL | Qt.Key_multiply)
        self.cell_mulAction.triggered.connect(self.actionMultiply)

        self.cell_divAction = QAction("&Divide", self)
        self.cell_divAction.setShortcut(Qt.CTRL | Qt.Key_division)
        self.cell_divAction.triggered.connect(self.actionDivide)

        self.fontAction = QAction("Font...", self)
        self.fontAction.setShortcut(Qt.CTRL | Qt.Key_F)
        self.fontAction.triggered.connect(self.selectFont)

        self.colorAction = QAction(QIcon(QPixmap(16, 16)), "Background &Color...", self)
        self.colorAction.triggered.connect(self.selectColor)

        self.clearAction = QAction("Clear", self)
        self.clearAction.setShortcut(Qt.Key_Delete)
        self.clearAction.triggered.connect(self.clear)

        self.aboutSpreadSheet = QAction("About Spreadsheet", self)
        self.aboutSpreadSheet.triggered.connect(self.showAbout)

        self.exitAction = QAction("E&xit", self)
        self.exitAction.setShortcut(QKeySequence.Quit)
        self.exitAction.triggered.connect(QApplication.instance().quit)

        self.printAction = QAction("&Print", self)
        self.printAction.setShortcut(QKeySequence.Print)
        self.printAction.triggered.connect(self.print_)

        self.firstSeparator = QAction(self)
        self.firstSeparator.setSeparator(True)

        self.secondSeparator = QAction(self)
        self.secondSeparator.setSeparator(True)
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def createActions(self):
        self.cell_sumAction = QAction("Sum", self)
        self.cell_sumAction.triggered.connect(self.actionSum)

        self.cell_addAction = QAction("&Add", self)
        self.cell_addAction.setShortcut(Qt.CTRL | Qt.Key_Plus)
        self.cell_addAction.triggered.connect(self.actionAdd)

        self.cell_subAction = QAction("&Subtract", self)
        self.cell_subAction.setShortcut(Qt.CTRL | Qt.Key_Minus)
        self.cell_subAction.triggered.connect(self.actionSubtract)

        self.cell_mulAction = QAction("&Multiply", self)
        self.cell_mulAction.setShortcut(Qt.CTRL | Qt.Key_multiply)
        self.cell_mulAction.triggered.connect(self.actionMultiply)

        self.cell_divAction = QAction("&Divide", self)
        self.cell_divAction.setShortcut(Qt.CTRL | Qt.Key_division)
        self.cell_divAction.triggered.connect(self.actionDivide)

        self.fontAction = QAction("Font...", self)
        self.fontAction.setShortcut(Qt.CTRL | Qt.Key_F)
        self.fontAction.triggered.connect(self.selectFont)

        self.colorAction = QAction(QIcon(QPixmap(16, 16)), "Background &Color...", self)
        self.colorAction.triggered.connect(self.selectColor)

        self.clearAction = QAction("Clear", self)
        self.clearAction.setShortcut(Qt.Key_Delete)
        self.clearAction.triggered.connect(self.clear)

        self.aboutSpreadSheet = QAction("About Spreadsheet", self)
        self.aboutSpreadSheet.triggered.connect(self.showAbout)

        self.exitAction = QAction("E&xit", self)
        self.exitAction.setShortcut(QKeySequence.Quit)
        self.exitAction.triggered.connect(QApplication.instance().quit)

        self.printAction = QAction("&Print", self)
        self.printAction.setShortcut(QKeySequence.Print)
        self.printAction.triggered.connect(self.print_)

        self.firstSeparator = QAction(self)
        self.firstSeparator.setSeparator(True)

        self.secondSeparator = QAction(self)
        self.secondSeparator.setSeparator(True)
项目:server    作者:happypandax    | 项目源码 | 文件源码
def create_ui(self):
        w = QWidget(self)
        settings_group = QGroupBox(t("", default="Configuration"), w)
        settings_group_l = QVBoxLayout(settings_group)
        settings = SettingsTabs()
        settings_group_l.addWidget(settings)

        buttons = QGroupBox(w)
        self.server_btn = QPushButton(self.start_ico, t("", default="Start server"))
        self.server_btn.clicked.connect(self.toggle_server)
        self.server_btn.setShortcut(Qt.CTRL | Qt.Key_S)

        #self.webclient_btn = QPushButton(self.start_ico, t("", default="Start webclient"))
        # self.webclient_btn.clicked.connect(self.toggle_client)
        # self.webclient_btn.setShortcut(Qt.CTRL|Qt.Key_W)

        open_config_btn = QPushButton(qta.icon("fa.cogs"), t("", default="Open configuration"))
        open_config_btn.clicked.connect(self.open_cfg)
        open_config_btn.setShortcut(Qt.CTRL | Qt.Key_C)

        convert_btn = QPushButton(qta.icon("fa.refresh"), t("", default="HP to HPX"))
        convert_btn.clicked.connect(self.convert_hp)

        for b in (self.server_btn, open_config_btn, convert_btn):
            b.setFixedHeight(40)
        button_layout = QHBoxLayout(buttons)
        button_layout.addWidget(self.server_btn)
        # button_layout.addWidget(self.webclient_btn)
        button_layout.addWidget(open_config_btn)
        button_layout.addWidget(convert_btn)

        infos = QGroupBox(t("", default="Info"))
        info_layout = QHBoxLayout(infos)
        version_layout = QFormLayout()
        version_layout.addRow(t("", default="Server version") +
                              ':', QLabel(".".join(str(x) for x in constants.version)))
        version_layout.addRow(t("", default="Webclient version") +
                              ':', QLabel(".".join(str(x) for x in constants.version_web)))
        version_layout.addRow(t("", default="Database version") +
                              ':', QLabel(".".join(str(x) for x in constants.version_db)))

        connect_layout = QFormLayout()
        connect_layout.addRow(t("", default="Server") + '@', QLabel(config.host.value + ':' + str(config.port.value)))
        connect_layout.addRow(t("", default="Webclient") + '@',
                              QLabel(config.host_web.value + ':' + str(config.port_web.value)))
        info_layout.addLayout(connect_layout)
        info_layout.addLayout(version_layout)

        main_layout = QVBoxLayout(w)
        main_layout.addWidget(settings_group)
        main_layout.addWidget(infos)
        main_layout.addWidget(buttons)
        self.setCentralWidget(w)

        self.tray.setIcon(QIcon(os.path.join(constants.dir_static, "favicon.ico")))
        self.tray.activated.connect(self.tray_activated)
        tray_menu = QMenu()
        tray_menu.addAction(t("", default="Show"), lambda: self.show())
        tray_menu.addSeparator()
        tray_menu.addAction(t("", default="Quit"), lambda: self.real_close())
        self.tray.setContextMenu(tray_menu)
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def createActions(self):
        self.cell_sumAction = QAction("Sum", self)
        self.cell_sumAction.triggered.connect(self.actionSum)

        self.cell_addAction = QAction("&Add", self)
        self.cell_addAction.setShortcut(Qt.CTRL | Qt.Key_Plus)
        self.cell_addAction.triggered.connect(self.actionAdd)

        self.cell_subAction = QAction("&Subtract", self)
        self.cell_subAction.setShortcut(Qt.CTRL | Qt.Key_Minus)
        self.cell_subAction.triggered.connect(self.actionSubtract)

        self.cell_mulAction = QAction("&Multiply", self)
        self.cell_mulAction.setShortcut(Qt.CTRL | Qt.Key_multiply)
        self.cell_mulAction.triggered.connect(self.actionMultiply)

        self.cell_divAction = QAction("&Divide", self)
        self.cell_divAction.setShortcut(Qt.CTRL | Qt.Key_division)
        self.cell_divAction.triggered.connect(self.actionDivide)

        self.fontAction = QAction("Font...", self)
        self.fontAction.setShortcut(Qt.CTRL | Qt.Key_F)
        self.fontAction.triggered.connect(self.selectFont)

        self.colorAction = QAction(QIcon(QPixmap(16, 16)), "Background &Color...", self)
        self.colorAction.triggered.connect(self.selectColor)

        self.clearAction = QAction("Clear", self)
        self.clearAction.setShortcut(Qt.Key_Delete)
        self.clearAction.triggered.connect(self.clear)

        self.aboutSpreadSheet = QAction("About Spreadsheet", self)
        self.aboutSpreadSheet.triggered.connect(self.showAbout)

        self.exitAction = QAction("E&xit", self)
        self.exitAction.setShortcut(QKeySequence.Quit)
        self.exitAction.triggered.connect(QApplication.instance().quit)

        self.printAction = QAction("&Print", self)
        self.printAction.setShortcut(QKeySequence.Print)
        self.printAction.triggered.connect(self.print_)

        self.firstSeparator = QAction(self)
        self.firstSeparator.setSeparator(True)

        self.secondSeparator = QAction(self)
        self.secondSeparator.setSeparator(True)