Python PyQt5.QtCore.Qt.LeftButton() Examples

The following are 30 code examples of PyQt5.QtCore.Qt.LeftButton(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt5.QtCore.Qt , or try the search function .
Example #1
Source File: mpvwidget.py    From vidcutter with GNU General Public License v3.0 10 votes vote down vote up
def mousePressEvent(self, event: QMouseEvent) -> None:
        event.accept()
        if event.button() == Qt.LeftButton:
            if self.parent is None:
                self.originalParent.playMedia()
            else:
                self.parent.playMedia() 
Example #2
Source File: webelem.py    From qutebrowser with GNU General Public License v3.0 8 votes vote down vote up
def _click_fake_event(self, click_target: usertypes.ClickTarget,
                          button: Qt.MouseButton = Qt.LeftButton) -> None:
        """Send a fake click event to the element."""
        pos = self._mouse_pos()

        log.webelem.debug("Sending fake click to {!r} at position {} with "
                          "target {}".format(self, pos, click_target))

        target_modifiers = {
            usertypes.ClickTarget.normal: Qt.NoModifier,
            usertypes.ClickTarget.window: Qt.AltModifier | Qt.ShiftModifier,
            usertypes.ClickTarget.tab: Qt.ControlModifier,
            usertypes.ClickTarget.tab_bg: Qt.ControlModifier,
        }
        if config.val.tabs.background:
            target_modifiers[usertypes.ClickTarget.tab] |= Qt.ShiftModifier
        else:
            target_modifiers[usertypes.ClickTarget.tab_bg] |= Qt.ShiftModifier

        modifiers = typing.cast(Qt.KeyboardModifiers,
                                target_modifiers[click_target])

        events = [
            QMouseEvent(QEvent.MouseMove, pos, Qt.NoButton, Qt.NoButton,
                        Qt.NoModifier),
            QMouseEvent(QEvent.MouseButtonPress, pos, button, button,
                        modifiers),
            QMouseEvent(QEvent.MouseButtonRelease, pos, button, Qt.NoButton,
                        modifiers),
        ]

        for evt in events:
            self._tab.send_event(evt)

        QTimer.singleShot(0, self._move_text_cursor) 
Example #3
Source File: notifications.py    From vidcutter with GNU General Public License v3.0 8 votes vote down vote up
def mousePressEvent(self, event: QMouseEvent):
        if event.button() == Qt.LeftButton:
            self.close() 
Example #4
Source File: mediastream.py    From vidcutter with GNU General Public License v3.0 7 votes vote down vote up
def mousePressEvent(self, event: QMouseEvent) -> None:
        if event.button() == Qt.LeftButton and self.checkbox is not None:
            self.checkbox.toggle()
        super(StreamSelectorLabel, self).mousePressEvent(event) 
Example #5
Source File: PushButtonDelegateQt.py    From KStock with GNU General Public License v3.0 6 votes vote down vote up
def editorEvent(self, event, model, option, index):
        ''' 
        Handle mouse events in cell.
        On left button release in this cell, call model's setData() method,
            wherein the button clicked action should be handled.
        Currently, the value supplied to setData() is the button text, but this is arbitrary.
        '''
        if event.button() == Qt.LeftButton:
            if event.type() == QEvent.MouseButtonPress:
                if option.rect.contains(event.pos()):
                    self._isMousePressed = True
                    return True
            elif event.type() == QEvent.MouseButtonRelease:
                self._isMousePressed = False
                if option.rect.contains(event.pos()):
                    model.setData(index, self.text, Qt.EditRole)  # Model should handle button click action in its setData() method.
                    return True
        return False 
Example #6
Source File: CheckBoxDelegateQt.py    From KStock with GNU General Public License v3.0 6 votes vote down vote up
def editorEvent(self, event, model, option, index):
        ''' 
        Change the data in the model and the state of the checkbox if the
        user presses the left mouse button and this cell is editable. Otherwise do nothing.
        '''
        if not (index.flags() & Qt.ItemIsEditable):
            return False
        if event.button() == Qt.LeftButton:
            if event.type() == QEvent.MouseButtonRelease:
                if self.getCheckBoxRect(option).contains(event.pos()):
                    self.setModelData(None, model, index)
                    return True
            elif event.type() == QEvent.MouseButtonDblClick:
                if self.getCheckBoxRect(option).contains(event.pos()):
                    return True
        return False 
Example #7
Source File: titlebar.py    From equant with GNU General Public License v2.0 6 votes vote down vote up
def mouseMoveEvent(self, event):
        if self.win.windowState() == Qt.WindowNoState:
            self.nheight = self.win.geometry().height()

        if event.buttons() == Qt.LeftButton and self.mPos:
            if event.pos() == self.mPos:
                return
            if self.win.windowState() == Qt.WindowMaximized:
                MaxWinWidth = self.width()        # 窗口最大化宽度
                WinX = self.win.geometry().x()    # 窗口屏幕左上角x坐标
                self.win.showNormal()
                self.buttonMaximum.setText('1')
                # 还原后的窗口宽和高
                nwidth = self.width()
                nheight = self.nheight
                x, y = event.globalPos().x(), event.globalPos().y()
                x = x - nwidth * (x-WinX)/MaxWinWidth

                self.win.setGeometry(x, 1, nwidth, nheight)
                return

            movePos = event.globalPos() - self.mPos
            self.mPos = event.globalPos()
            self.win.move(self.win.pos() + movePos)
        return QWidget().mouseMoveEvent(event) 
Example #8
Source File: miscwidgets.py    From qutebrowser with GNU General Public License v3.0 6 votes vote down vote up
def mousePressEvent(self, e):
        """Toggle the fold if the widget was pressed.

        Args:
            e: The QMouseEvent.
        """
        if e.button() == Qt.LeftButton:
            e.accept()
            self.toggle()
        else:
            super().mousePressEvent(e) 
Example #9
Source File: paint.py    From 15-minute-apps with MIT License 6 votes vote down vote up
def generic_mousePressEvent(self, e):
        self.last_pos = e.pos()

        if e.button() == Qt.LeftButton:
            self.active_color = self.primary_color
        else:
            self.active_color = self.secondary_color 
Example #10
Source File: paint.py    From 15-minute-apps with MIT License 6 votes vote down vote up
def text_mousePressEvent(self, e):
        if e.button() == Qt.LeftButton and self.current_pos is None:
            self.current_pos = e.pos()
            self.current_text = ""
            self.timer_event = self.text_timerEvent

        elif e.button() == Qt.LeftButton:

            self.timer_cleanup()
            # Draw the text to the image
            p = QPainter(self.pixmap())
            p.setRenderHints(QPainter.Antialiasing)
            font = build_font(self.config)
            p.setFont(font)
            pen = QPen(self.primary_color, 1, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
            p.setPen(pen)
            p.drawText(self.current_pos, self.current_text)
            self.update()

            self.reset_mode()

        elif e.button() == Qt.RightButton and self.current_pos:
            self.reset_mode() 
Example #11
Source File: occt_widget.py    From CQ-editor with Apache License 2.0 6 votes vote down vote up
def mouseMoveEvent(self,event):
        
        pos = event.pos()
        x,y = pos.x(),pos.y()
        
        if event.buttons() == Qt.LeftButton:
            self.view.Rotation(x,y)
            
        elif event.buttons() == Qt.MiddleButton:
            self.view.Pan(x - self.old_pos.x(),
                          self.old_pos.y() - y, theToStart=True)
            
        elif event.buttons() == Qt.RightButton:
            self.view.ZoomAtPoint(self.old_pos.x(), y,
                                  x, self.old_pos.y())
        
        self.old_pos = pos 
Example #12
Source File: cue_widget.py    From linux-show-player with GNU General Public License v3.0 6 votes vote down vote up
def mouseMoveEvent(self, event):
        if (event.buttons() == Qt.LeftButton and
                (event.modifiers() == Qt.ControlModifier or
                         event.modifiers() == Qt.ShiftModifier)):
            mime_data = QMimeData()
            mime_data.setText(PageWidget.DRAG_MAGIC)

            drag = QDrag(self)
            drag.setMimeData(mime_data)
            drag.setPixmap(self.grab(self.rect()))

            if event.modifiers() == Qt.ControlModifier:
                drag.exec_(Qt.MoveAction)
            else:
                drag.exec_(Qt.CopyAction)

            event.accept()
        else:
            event.ignore() 
Example #13
Source File: qclickslider.py    From linux-show-player with GNU General Public License v3.0 6 votes vote down vote up
def mousePressEvent(self, e):
        cr = self._control_rect()

        if e.button() == Qt.LeftButton and not cr.contains(e.pos()):
            # Set the value to the minimum
            value = self.minimum()
            # zmax is the maximum value starting from zero
            zmax = self.maximum() - self.minimum()

            if self.orientation() == Qt.Vertical:
                # Add the current position multiplied for value/size ratio
                value += (self.height() - e.y()) * (zmax / self.height())
            else:
                value += e.x() * (zmax / self.width())

            if self.value() != value:
                self.setValue(value)
                self.sliderJumped.emit(self.value())
                e.accept()
            else:
                e.ignore()
        else:
            super().mousePressEvent(e) 
Example #14
Source File: QtImageViewer.py    From PyQtImageViewer with MIT License 6 votes vote down vote up
def mouseReleaseEvent(self, event):
        """ Stop mouse pan or zoom mode (apply zoom if valid).
        """
        QGraphicsView.mouseReleaseEvent(self, event)
        scenePos = self.mapToScene(event.pos())
        if event.button() == Qt.LeftButton:
            self.setDragMode(QGraphicsView.NoDrag)
            self.leftMouseButtonReleased.emit(scenePos.x(), scenePos.y())
        elif event.button() == Qt.RightButton:
            if self.canZoom:
                viewBBox = self.zoomStack[-1] if len(self.zoomStack) else self.sceneRect()
                selectionBBox = self.scene.selectionArea().boundingRect().intersected(viewBBox)
                self.scene.setSelectionArea(QPainterPath())  # Clear current selection area.
                if selectionBBox.isValid() and (selectionBBox != viewBBox):
                    self.zoomStack.append(selectionBBox)
                    self.updateViewer()
            self.setDragMode(QGraphicsView.NoDrag)
            self.rightMouseButtonReleased.emit(scenePos.x(), scenePos.y()) 
Example #15
Source File: QVTKRenderWindowInteractor.py    From pyCGNS with GNU Lesser General Public License v2.1 6 votes vote down vote up
def mousePressEvent(self, ev):
        ctrl, shift = self._GetCtrlShift(ev)
        repeat = 0
        if ev.type() == QEvent.MouseButtonDblClick:
            repeat = 1
        self._Iren.SetEventInformationFlipY(ev.x(), ev.y(),
                                            ctrl, shift, chr(0), repeat, None)

        self._ActiveButton = ev.button()

        if self._ActiveButton == Qt.LeftButton:
            self._Iren.LeftButtonPressEvent()
        elif self._ActiveButton == Qt.RightButton:
            self._Iren.RightButtonPressEvent()
        elif self._ActiveButton == Qt.MidButton:
            self._Iren.MiddleButtonPressEvent() 
Example #16
Source File: elementmaster.py    From Pythonic with GNU General Public License v3.0 6 votes vote down vote up
def mousePressEvent(self, event):
            
        logging.debug('ElementMaster::mousePressEvent() called')
        # uncomment this for debugging purpose
        #self.listChild()

        if event.buttons() != Qt.LeftButton:
            return

        icon = QLabel()

        mimeData = QMimeData()
        mime_text = str(self.row) + str(self.column) + str(self.__class__.__name__)
        mimeData.setText(mime_text)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(self.pixmap)
        drag.setHotSpot(event.pos() - self.rect().topLeft())

        if drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction) == Qt.MoveAction:
            icon.close()
        else:
            icon.show()
            icon.setPixmap(self.pixmap) 
Example #17
Source File: barraTitulo.py    From PyQt5 with MIT License 5 votes vote down vote up
def mouseReleaseEvent(self, QMouseEvent):
        if QMouseEvent.button() == Qt.LeftButton:
            self.clicked.emit() 
Example #18
Source File: CColorPicker.py    From CustomWidgets with GNU General Public License v3.0 5 votes vote down vote up
def mouseMoveEvent(self, event):
        if event.buttons() == Qt.LeftButton and self.mPos:
            if not self.colorPanel.geometry().contains(self.mPos):
                self.move(self.mapToGlobal(event.pos() - self.mPos))
        event.accept() 
Example #19
Source File: dragbutton.py    From python with Apache License 2.0 5 votes vote down vote up
def mousePressEvent(self, e):

        super().mousePressEvent(e)

        if e.button() == Qt.LeftButton:
            print('press') 
Example #20
Source File: interruptorPalanca.py    From PyQt5 with MIT License 5 votes vote down vote up
def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.ultimo = True
            self.inicio = event.pos()
            self.pressing = True
            self.actualizarEstado() 
Example #21
Source File: interruptorPalanca.py    From PyQt5 with MIT License 5 votes vote down vote up
def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.mover.setY(1)
            
            if event.pos().x() < Frame.VALOR / 2:
                self.mover.setX(Frame.MIN_VALOR)
            elif event.pos().x() > Frame.VALOR / 2:
                self.mover.setX(Frame.MAX_VALOR - self.parent.button.width())

            self.animacion = QPropertyAnimation(self.parent.button, b"pos")
            self.animacion.setDuration(150)
            self.animacion.setEndValue(self.mover)
            self.animacion.valueChanged.connect(self.actualizarEstado)
            self.animacion.finished.connect(self.emitirEstado)
            self.animacion.start(QAbstractAnimation.DeleteWhenStopped) 
Example #22
Source File: barraTitulo.py    From PyQt5 with MIT License 5 votes vote down vote up
def mouseDoubleClickEvent(self, event):
        if event.buttons() == Qt.LeftButton:
            if self.parent.isMaximized():
                self.parent.showNormal()
                self.buttonMaxRes.setIcon(QApplication.style().standardIcon(QStyle.SP_TitleBarMaxButton))
                self.buttonMaxRes.setToolTip("Maximizar")
            else:
                self.parent.showMaximized()
                self.buttonMaxRes.setIcon(QApplication.style().standardIcon(QStyle.SP_TitleBarNormalButton))
                self.buttonMaxRes.setToolTip("Restaurar") 
Example #23
Source File: interruptorPalanca.py    From PyQt5 with MIT License 5 votes vote down vote up
def mouseDoubleClickEvent(self, event):
        if event.button() == Qt.LeftButton:
            self.ultimo = False 
Example #24
Source File: CFramelessWidget.py    From CustomWidgets with GNU General Public License v3.0 5 votes vote down vote up
def mousePressEvent(self, event):
        """鼠标按下设置标志
        :param event:
        """
        if not self.isResizable() or self.childAt(event.pos()):
            return
        self.dragParams['x'] = event.x()
        self.dragParams['y'] = event.y()
        self.dragParams['globalX'] = event.globalX()
        self.dragParams['globalY'] = event.globalY()
        self.dragParams['width'] = self.width()
        self.dragParams['height'] = self.height()
        if event.button() == Qt.LeftButton and self.dragParams['type'] != 0 \
                and not self.isMaximized() and not self.isFullScreen():
            self.dragParams['draging'] = True 
Example #25
Source File: QtImageViewer.py    From PyQtImageViewer with MIT License 5 votes vote down vote up
def mouseDoubleClickEvent(self, event):
        """ Show entire image.
        """
        scenePos = self.mapToScene(event.pos())
        if event.button() == Qt.LeftButton:
            self.leftMouseButtonDoubleClicked.emit(scenePos.x(), scenePos.y())
        elif event.button() == Qt.RightButton:
            if self.canZoom:
                self.zoomStack = []  # Clear zoom stack.
                self.updateViewer()
            self.rightMouseButtonDoubleClicked.emit(scenePos.x(), scenePos.y())
        QGraphicsView.mouseDoubleClickEvent(self, event) 
Example #26
Source File: Q7VTKRenderWindowInteractor.py    From pyCGNS with GNU Lesser General Public License v2.1 5 votes vote down vote up
def mousePressEvent(self, ev):
        ctrl, shift = self._GetCtrlShift(ev)
        repeat = 0
        if ev.type() == QEvent.MouseButtonDblClick:
            repeat = 1
        self._Iren.SetEventInformationFlipY(ev.x(), ev.y(),
                                            ctrl, shift, chr(0), repeat, None)

        self._ActiveButton = ev.button()

        if self._ActiveButton == Qt.LeftButton:
            self._Iren.LeftButtonPressEvent()
        elif self._ActiveButton == Qt.RightButton:
            self._Iren.RightButtonPressEvent()
        elif self._ActiveButton == Qt.MidButton:
            self._Iren.MiddleButtonPressEvent()

    #def mouseReleaseEvent(self, ev):
    #    ctrl, shift = self._GetCtrlShift(ev)
    #    self._Iren.SetEventInformationFlipY(ev.x(), ev.y(),
    #                                       ctrl, shift, chr(0), 0, None)

    #    if self._ActiveButton == Qt.LeftButton:
    #        self._Iren.LeftButtonReleaseEvent()
    #    elif self._ActiveButton == Qt.RightButton:
    #        self._Iren.RightButtonReleaseEvent()
    #    elif self._ActiveButton == Qt.MidButton:
    #        self._Iren.MiddleButtonReleaseEvent() 
Example #27
Source File: eventfilter.py    From qutebrowser with GNU General Public License v3.0 5 votes vote down vote up
def _mousepress_backforward(self, e):
        """Handle back/forward mouse button presses.

        Args:
            e: The QMouseEvent.

        Return:
            True if the event should be filtered, False otherwise.
        """
        if (not config.val.input.mouse.back_forward_buttons and
                e.button() in [Qt.XButton1, Qt.XButton2]):
            # Back and forward on mice are disabled
            return

        if e.button() in [Qt.XButton1, Qt.LeftButton]:
            # Back button on mice which have it, or rocker gesture
            if self._tab.history.can_go_back():
                self._tab.history.back()
            else:
                message.error("At beginning of history.")
        elif e.button() in [Qt.XButton2, Qt.RightButton]:
            # Forward button on mice which have it, or rocker gesture
            if self._tab.history.can_go_forward():
                self._tab.history.forward()
            else:
                message.error("At end of history.") 
Example #28
Source File: QVTKRenderWindowInteractor.py    From pyCGNS with GNU Lesser General Public License v2.1 5 votes vote down vote up
def mouseReleaseEvent(self, ev):
        ctrl, shift = self._GetCtrlShift(ev)
        self._Iren.SetEventInformationFlipY(ev.x(), ev.y(),
                                            ctrl, shift, chr(0), 0, None)

        if self._ActiveButton == Qt.LeftButton:
            self._Iren.LeftButtonReleaseEvent()
        elif self._ActiveButton == Qt.RightButton:
            self._Iren.RightButtonReleaseEvent()
        elif self._ActiveButton == Qt.MidButton:
            self._Iren.MiddleButtonReleaseEvent() 
Example #29
Source File: CTitleBar.py    From CustomWidgets with GNU General Public License v3.0 5 votes vote down vote up
def mousePressEvent(self, event):
        """鼠标按下记录坐标
        :param event:
        """
        if event.button() == Qt.LeftButton:
            self.mPos = event.pos() 
Example #30
Source File: QtImageViewer.py    From PyQtImageViewer with MIT License 5 votes vote down vote up
def mousePressEvent(self, event):
        """ Start mouse pan or zoom mode.
        """
        scenePos = self.mapToScene(event.pos())
        if event.button() == Qt.LeftButton:
            if self.canPan:
                self.setDragMode(QGraphicsView.ScrollHandDrag)
            self.leftMouseButtonPressed.emit(scenePos.x(), scenePos.y())
        elif event.button() == Qt.RightButton:
            if self.canZoom:
                self.setDragMode(QGraphicsView.RubberBandDrag)
            self.rightMouseButtonPressed.emit(scenePos.x(), scenePos.y())
        QGraphicsView.mousePressEvent(self, event)