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

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

项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            for recordIndex, rect in self._optionsRects.items():
                if QRect(*rect).contains(event.pos()):
                    self._clickedIndex = recordIndex
                    self._oldSelection = self._selection
                    self._selection = {recordIndex}
                    if self._selectionMode > 1 and QApplication.keyboardModifiers(
                            ) & Qt.ShiftModifier:
                        shiftSelection = self._selection ^ self._oldSelection
                        if shiftSelection:
                            self._selection = shiftSelection
                    else:
                        self._selection |= self._oldSelection
                    break
            self.update()
        else:
            super().mousePressEvent(event)
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def mouseReleaseEvent(self, event):
        if event.button() == Qt.LeftButton:
            clickedRect = self._optionsRects[self._clickedIndex]
            if QRect(*clickedRect).contains(event.pos()):
                self._selection = {self._clickedIndex}
                if self._selectionMode > 1 and QApplication.keyboardModifiers(
                        ) & Qt.ShiftModifier:
                    shiftSelection = self._selection ^ self._oldSelection
                    if shiftSelection:
                        self._selection = shiftSelection
                self.clicked.emit()
            else:
                self._selection = self._oldSelection
            self.update()
            del self._clickedIndex
            del self._oldSelection
        else:
            super().mouseReleaseEvent(event)
项目: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
项目:Dolphin-Updater    作者:nbear3    | 项目源码 | 文件源码
def update_version(self, message):
        if message == 'finished':
            self.version.setText(self.version.placeholderText())
            self.version.setPlaceholderText("Installation Status Unknown")
            self.version_status.setPixmap(self.check)
            self._udc.set_user_version(self.version.text())
            if self.auto_launch_check.isChecked() and QApplication.keyboardModifiers() != Qt.ShiftModifier:
                QTimer.singleShot(1000, self.launch_dolphin)
        else:
            self.version.setPlaceholderText(message)
项目:Dolphin-Updater    作者:nbear3    | 项目源码 | 文件源码
def update_current(self, current):
        self.current.setText(current)
        if self.version.text() == self.current.text():
            self.version_status.setPixmap(self.check)
            if self.auto_launch_check.isChecked() and QApplication.keyboardModifiers() != Qt.ShiftModifier:
                QTimer.singleShot(1000, self.launch_dolphin)
        else:
            self.version_status.setPixmap(self.cancel)
            if self.auto_launch_check.isChecked() and self.dolphin_dir.text():
                self.download_new()
项目: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
项目: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)
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def mouseReleaseEvent(self, event):
        if event.button() in (Qt.LeftButton, Qt.RightButton):
            self._maybeDragPosition = None
            # XXX: we should use modifiers registered on click
            if not event.modifiers() & Qt.ShiftModifier:
                if self._lastSelectedCell is not None:
                    self._selection = {self._lastSelectedCell}
                else:
                    self._selection = set()
                self.update()
            self._oldSelection = None
        else:
            super(GlyphCellWidget, self).mouseReleaseEvent(event)
项目:defconQt    作者:trufont    | 项目源码 | 文件源码
def _arrowKeyPressEvent(self, event):
        count = event.count()
        key = event.key()
        modifiers = event.modifiers()
        # TODO: it might be the case that self._lastSelectedCell cannot be None
        # when we arrive here whatsoever
        if self._lastSelectedCell is not None:
            if key == Qt.Key_Up:
                delta = -self._columnCount
            elif key == Qt.Key_Down:
                delta = self._columnCount
            elif key == Qt.Key_Left:
                delta = -1
            elif key == Qt.Key_Right:
                delta = 1
            newSel = self._lastSelectedCell + delta * count
            if newSel < 0 or newSel >= len(self._glyphs):
                return
            if modifiers & Qt.ShiftModifier:
                self._selection |= self._linearSelection(newSel)
            else:
                self._selection = {newSel}
            self._lastSelectedCell = newSel
            self.scrollToCell(newSel)
            self.selectionChanged.emit()
            self.update()
项目: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)
项目: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])
项目:urh    作者:jopohl    | 项目源码 | 文件源码
def mousePressEvent(self, event: QMouseEvent):
        if self.scene() is None:
            return

        cursor = self.cursor().shape()
        has_shift_modifier = event.modifiers() == Qt.ShiftModifier
        is_in_shift_mode = (has_shift_modifier and self.hold_shift_to_drag) \
                           or (not has_shift_modifier and not self.hold_shift_to_drag) \
                              and cursor != Qt.SplitHCursor and cursor != Qt.SplitVCursor

        if event.buttons() == Qt.LeftButton and is_in_shift_mode:
            self.setCursor(Qt.ClosedHandCursor)
            self.grab_start = event.pos()
        elif event.buttons() == Qt.LeftButton:
            if self.is_pos_in_separea(self.mapToScene(event.pos())):
                self.separation_area_moving = True
                self.setCursor(Qt.SplitVCursor)

            elif self.selection_area.is_empty or self.selection_area.selected_edge is None:
                # Create new selection
                self.mouse_press_pos = event.pos()
                self.mouse_pos = event.pos()
                scene_pos = self.mapToScene(self.mouse_press_pos)
                self.__set_selection_area(x=scene_pos.x(), y=scene_pos.y(), w=0, h=0)
                self.selection_area.finished = False

            elif self.selection_area.selected_edge is not None:
                self.selection_area.resizing = True