Python PyQt5.QtCore.Qt 模块,ControlModifier() 实例源码

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

项目: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
项目:mhri    作者:mhri    | 项目源码 | 文件源码
def _GetCtrlShift(self, ev):
        ctrl = shift = False

        if hasattr(ev, 'modifiers'):
            if ev.modifiers() & Qt.ShiftModifier:
                shift = True
            if ev.modifiers() & Qt.ControlModifier:
                ctrl = True
        else:
            if self.__saveModifiers & Qt.ShiftModifier:
                shift = True
            if self.__saveModifiers & Qt.ControlModifier:
                ctrl = True

        return ctrl, shift
项目:pyree-old    作者:DrLuke    | 项目源码 | 文件源码
def keyPressEvent(self, QKeyEvent):
        if QKeyEvent.key() == Qt.Key_S and QKeyEvent.modifiers() == Qt.ControlModifier:
            self.saveProjectDialog()
        else:
            super(PyreeMainWindow, self).keyPressEvent(QKeyEvent)
项目:Cite    作者:siudej    | 项目源码 | 文件源码
def on_arxiv_clicked(self):
        """ Execute arxiv search. """
        if QApplication.keyboardModifiers() == Qt.ControlModifier:
            self.startWorker(ArXiv(), "Searching arXiv ...", website=True)
        else:
            self.startWorker(ArXiv(), "Searching arXiv ...")
项目:Cite    作者:siudej    | 项目源码 | 文件源码
def on_msn_clicked(self):
        """ Execute MathSciNet search. """
        if QApplication.keyboardModifiers() == Qt.ControlModifier:
            self.startWorker(MathSciNet(), "Searching MathSciNet ...",
                             website=True)
        else:
            self.startWorker(MathSciNet(), "Searching MathSciNet ...")
项目:Cite    作者:siudej    | 项目源码 | 文件源码
def eventFilter(self, source, event):
        """ Add/remove a few keyboard and mouse events. """
        if source is self.searchQuery:
            if event.type() == QEvent.KeyPress:
                if event.key() == Qt.Key_Return:
                    if event.modifiers() == Qt.ShiftModifier:
                        self.on_arxiv_clicked()
                        return True
                    elif event.modifiers() == Qt.ControlModifier:
                        self.on_msn_clicked()
                        return True
                    elif event.modifiers() == Qt.AltModifier:
                        self.on_zbl_clicked()
                        return True
        return QMainWindow.eventFilter(self, source, event)
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def mousePressEvent(self, event):
        if event.button() in (Qt.LeftButton, Qt.RightButton):
            self._oldSelection = set(self._selection)
            index = self._findIndexForEvent(event)
            modifiers = event.modifiers()

            if index is None:
                if not (modifiers & Qt.ControlModifier or
                        modifiers & Qt.ShiftModifier):
                    # TODO: consider setSelection(None)
                    self.setSelection(set())
                return

            if modifiers & Qt.ControlModifier:
                if index in self._selection:
                    self._selection.remove(index)
                else:
                    self._selection.add(index)
            elif modifiers & Qt.ShiftModifier:
                self._selection = self._linearSelection(index)
            elif index not in self._selection:
                self._selection = {index}
            else:
                self._maybeDragPosition = event.localPos()
            self._lastSelectedCell = index
            self.selectionChanged.emit()
            self.update()
        else:
            super(GlyphCellWidget, self).mousePressEvent(event)
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def mouseMoveEvent(self, event):
        if event.buttons() & (Qt.LeftButton | Qt.RightButton):
            index = self._findIndexForEvent(event, True)
            if index == self._lastSelectedCell:
                return
            if self.maybeExecuteDrag(event):
                return
            self.scrollToCell(index)
            if index >= len(self._glyphs):
                return

            modifiers = event.modifiers()
            if modifiers & Qt.ControlModifier:
                if index in self._selection and index in self._oldSelection:
                    self._selection.remove(index)
                elif index not in self._selection and \
                        index not in self._oldSelection:
                    self._selection.add(index)
            elif modifiers & Qt.ShiftModifier:
                self._selection = self._linearSelection(index)
            else:
                self._selection = {index}
            self._lastSelectedCell = index
            self.selectionChanged.emit()
            self.update()
        else:
            super(GlyphCellWidget, self).mouseMoveEvent(event)
项目:ciba    作者:FindHao    | 项目源码 | 文件源码
def keyPressEvent(self, e):
        keyEvent = QKeyEvent(e)
        ctrl = e.modifiers() & Qt.ControlModifier
        shift = e.modifiers() & Qt.ShiftModifier
        if keyEvent.key() == QtCore.Qt.Key_Escape:
            self.hide()
        # ctrl+c ??????????ctrl+shift+c?????????
        elif ctrl and keyEvent.key() == QtCore.Qt.Key_C:
            self.clipboard.setText(self.query.word.text)
        elif ctrl and keyEvent.key() == QtCore.Qt.Key_C and shift:
            self.clipboard.setText(self.query.word.raw_text)
项目:uitester    作者:IfengAutomation    | 项目源码 | 文件源码
def keyPressEvent(self, e):
        completion_prefix = self.text_under_cursor()
        if self.cmp and self.popup_widget.func_list_widget.isVisible():
            current_row = self.popup_widget.func_list_widget.currentRow()
            if e.key() == Qt.Key_Down:
                self.current_item_down(current_row)
                return

            if e.key() == Qt.Key_Up:
                self.current_item_up(current_row)
                return

            if e.key() in (Qt.Key_Return, Qt.Key_Enter):
                selected_word = self.popup_widget.func_list_widget.currentItem().text()
                self.insert_func_name_signal.emit(completion_prefix, selected_word)
                return

        if e.key() in (Qt.Key_Return, Qt.Key_Enter):
            self.parse_content()

        is_shortcut = ((e.modifiers() & Qt.ControlModifier) and e.key() == Qt.Key_E)  # shortcut key:ctrl + e
        if is_shortcut:
            self.cmp.update("", self.popup_widget)
            self.update_popup_widget_position()
            self.activateWindow()
            return

        if not self.cmp or not is_shortcut:
            super(TextEdit, self).keyPressEvent(e)
项目:pisi-player    作者:mthnzbk    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape and self.isFullScreen():
            self.showNormal()

        if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_Q:
            self.close()
            sys.exit()

        if event.key() == Qt.Key_Space:
            if self.player.player.state() == self.player.player.PlayingState:
                self.player.pause()
            elif self.player.player.state() == self.player.player.StoppedState or self.player.player.PausedState:
                self.player.play()

        if event.key() == Qt.Key_Plus:
            self.player.setVolume(self.player.volume() + 5)

        if event.key() == Qt.Key_Minus:
            self.player.setVolume(self.player.volume() - 5)

        if event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_M:
            self.player.setMuted(not self.player.isMuted())

        if event.key() == Qt.Key_Right:
            self.player.player.setPosition(self.player.player.position() + 10000)

        if event.key() == Qt.Key_Left:
            self.player.player.setPosition(self.player.player.position() - 10000)

        if event.key() == Qt.Key_Up:
            self.player.player.setPosition(self.player.player.position() + 60000)

        if event.key() == Qt.Key_Down:
            self.player.player.setPosition(self.player.player.position() - 60000)

        super().keyPressEvent(event)
项目:repo-checker    作者:1dot75cm    | 项目源码 | 文件源码
def itemClickedForOpenUrlSlot(self, item):
        """Ctrl+left ????"""
        # http://stackoverflow.com/questions/3100090/
        if item.column() == 1 and item.text() and \
                qApp.keyboardModifiers() == Qt.ControlModifier:
            QDesktopServices.openUrl(QUrl(item.text()))  # open url
项目:uPyLoader    作者:BetaRavener    | 项目源码 | 文件源码
def eventFilter(self, target, event):
        def match(s1, s2):
            for x in s2:
                if s1.matches(x) == QKeySequence.ExactMatch:
                    return True
            return False

        if target == self.inputTextBox:
            if isinstance(event, QKeyEvent):
                if event.type() == QKeyEvent.KeyPress:
                    event_sequence = QtHelper.key_event_sequence(event)
                    if match(event_sequence, Settings().new_line_key):
                        return False
                    if match(event_sequence, Settings().send_key):
                        self.send_input()
                        return True
                    if event.key() == Qt.Key_Tab:
                        self.inputTextBox.insertPlainText(" "*Settings().terminal_tab_spaces)
                        return True
                    if event.key() == Qt.Key_Up and (event.modifiers() & Qt.ControlModifier):
                        if self._input_history_index > 0:
                            self._input_history_index -= 1
                            self.inputTextBox.clear()
                            self.inputTextBox.setPlainText(self.terminal.input(self._input_history_index))
                    if event.key() == Qt.Key_Down and (event.modifiers() & Qt.ControlModifier):
                        if self._input_history_index < self.terminal.last_input_idx():
                            self._input_history_index += 1
                            self.inputTextBox.clear()
                            self.inputTextBox.setPlainText(self.terminal.input(self._input_history_index))
        elif target == self.outputTextEdit:
            if isinstance(event, QKeyEvent):
                if event.type() == QEvent.KeyPress:
                    if event.key() == Qt.Key_Up:
                        self.connection.send_bytes(b"\x1b[A")
                    if event.key() == Qt.Key_Down:
                        self.connection.send_bytes(b"\x1b[B")
                    else:
                        t = event.text()
                        if t:
                            self.connection.send_character(t)
                    return True
        elif target == self.outputTextEdit.verticalScrollBar():
            if isinstance(event, QHideEvent):
                return True
        return False
项目:gpvdm    作者:roderickmackenzie    | 项目源码 | 文件源码
def keyPressEvent(self, event):
        keyname=event.key()
        if (keyname>64 and keyname<91 ) or (keyname>96 and keyname<123):
            modifiers = event.modifiers()
            keyname=chr(keyname)
            if keyname.isalpha()==True:
                if Qt.ShiftModifier == modifiers:
                    keyname=keyname.upper()
                else:
                    keyname=keyname.lower()
        else:
            return

        if keyname=="a":
            self.do_plot()

        elif keyname=='g':
            if self.data[0].grid==False:
                for i in range(0,len(self.ax)):
                    self.ax[i].grid(True)
                self.data[0].grid=True
            else:
                for i in range(0,len(self.ax)):
                    self.ax[i].grid(False)
                self.data[0].grid=False
        elif keyname=="r":
            if self.lx==None:
                for i in range(0,len(self.ax)):
                    self.lx = self.ax[i].axhline(color='k')
                    self.ly = self.ax[i].axvline(color='k')
            self.lx.set_ydata(self.ydata)
            self.ly.set_xdata(self.xdata)

        elif keyname=="l":
            if self.data[0].logy==True:
                self.data[0].logy=False
                for i in range(0,len(self.ax)):
                    self.ax[i].set_yscale("linear")
            else:
                self.data[0].logy=True
                for i in range(0,len(self.ax)):
                    self.ax[i].set_yscale("log")

        elif keyname=="L":
            if self.data[0].logx==True:
                self.data[0].logx=False
                for i in range(0,len(self.ax)):
                    self.ax[i].set_xscale("linear")
            else:
                self.data[0].logx=True
                for i in range(0,len(self.ax)):
                    self.ax[i].set_xscale("log")

        elif keyname=="q":
            self.destroy()

        elif  modifiers == Qt.ControlModifier and keyname=='c':
            self.do_clip()

        self.fig.canvas.draw()
        plot_save_oplot_file(self.config_file,self.data[0])