Python PyQt5.QtGui.QWheelEvent() Examples

The following are 14 code examples for showing how to use PyQt5.QtGui.QWheelEvent(). These examples are extracted from open source projects. 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 check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .

Example 1
Project: track   Author: frans-fuerst   File: mainwindow.py    License: Apache License 2.0 7 votes vote down vote up
def event(self, e):
        if not isinstance(e, (
                QtCore.QEvent,
                QtCore.QChildEvent,
                QtCore.QDynamicPropertyChangeEvent,
                QtGui.QPaintEvent,
                QtGui.QHoverEvent,
                QtGui.QMoveEvent,
                QtGui.QEnterEvent,
                QtGui.QResizeEvent,
                QtGui.QShowEvent,
                QtGui.QPlatformSurfaceEvent,
                QtGui.QWindowStateChangeEvent,
                QtGui.QKeyEvent,
                QtGui.QWheelEvent,
                QtGui.QMouseEvent,
                QtGui.QFocusEvent,
                QtGui.QHelpEvent,
                QtGui.QHideEvent,
                QtGui.QCloseEvent,
                QtGui.QInputMethodQueryEvent,
                QtGui.QContextMenuEvent,
                )):
            log().warning("unknown event: %r %r", e.type(), e)
        return super().event(e) 
Example 2
Project: vidcutter   Author: ozmartian   File: mpvwidget.py    License: GNU General Public License v3.0 5 votes vote down vote up
def wheelEvent(self, event: QWheelEvent) -> None:
        self.parent.seekSlider.wheelEvent(event) 
Example 3
Project: vidcutter   Author: ozmartian   File: videoslider.py    License: GNU General Public License v3.0 5 votes vote down vote up
def wheelEvent(self, event: QWheelEvent) -> None:
        if self.parent.mediaAvailable:
            if event.angleDelta().y() > 0:
                self.parent.mpvWidget.frameBackStep()
            else:
                self.parent.mpvWidget.frameStep()
            self.parent.setPlayButton(False)
            event.accept() 
Example 4
Project: CvStudio   Author: haruiz   File: image_dialog.py    License: MIT License 5 votes vote down vote up
def wheelEvent(self, event: QWheelEvent):
        adj = (event.angleDelta().y() / 120) * 0.1
        self.scale(1 + adj, 1 + adj) 
Example 5
Project: CvStudio   Author: haruiz   File: image_graphics_view.py    License: MIT License 5 votes vote down vote up
def wheelEvent(self, event: QWheelEvent):
        adj = (event.angleDelta().y() / 120) * 0.1
        self.scale(1 + adj, 1 + adj) 
Example 6
Project: CvStudio   Author: haruiz   File: imageViewer.py    License: MIT License 5 votes vote down vote up
def wheelEvent(self, wheelEvent):
        """Overrides the wheelEvent to handle zooming.

        :param QWheelEvent wheelEvent: instance of |QWheelEvent|"""
        assert isinstance(wheelEvent, QtGui.QWheelEvent)
        if wheelEvent.modifiers() & QtCore.Qt.ControlModifier:
            self.wheelNotches.emit(wheelEvent.angleDelta().y() / 240.0)
            wheelEvent.accept()
        else:
            super(SynchableGraphicsView, self).wheelEvent(wheelEvent) 
Example 7
Project: ezdxf   Author: mozman   File: cad_viewer.py    License: MIT License 5 votes vote down vote up
def wheelEvent(self, event: qg.QWheelEvent) -> None:
        # dividing by 120 gets number of notches on a typical scroll wheel. See QWheelEvent documentation
        delta_notches = event.angleDelta().y() / 120
        zoom_per_scroll_notch = 0.2
        factor = 1 + zoom_per_scroll_notch * delta_notches
        resulting_zoom = self._zoom * factor
        if resulting_zoom < self._zoom_limits[0]:
            factor = self._zoom_limits[0] / self._zoom
        elif resulting_zoom > self._zoom_limits[1]:
            factor = self._zoom_limits[1] / self._zoom
        self.scale(factor, factor)
        self._zoom *= factor 
Example 8
Project: Python-CTPAPI   Author: nicai0609   File: candle_demo.py    License: MIT License 5 votes vote down vote up
def wheelEvent(self, event: QtGui.QWheelEvent) -> None:
        """
        Reimplement this method of parent to zoom in/out.
        """
        delta = event.angleDelta()

        if delta.y() > 0:
            self._on_key_up()
        elif delta.y() < 0:
            self._on_key_down() 
Example 9
Project: urh   Author: jopohl   File: SpectrumDialogController.py    License: GNU General Public License v3.0 5 votes vote down vote up
def on_graphics_view_wheel_event_triggered(self, event: QWheelEvent):
        self.ui.sliderYscale.wheelEvent(event) 
Example 10
Project: urh   Author: jopohl   File: ZoomableGraphicView.py    License: GNU General Public License v3.0 5 votes vote down vote up
def wheelEvent(self, event: QWheelEvent):
        zoom_factor = 1.001 ** event.angleDelta().y()
        self.zoom(zoom_factor, cursor_pos=event.pos()) 
Example 11
Project: urh   Author: jopohl   File: LiveGraphicView.py    License: GNU General Public License v3.0 5 votes vote down vote up
def wheelEvent(self, event: QWheelEvent):
        self.wheel_event_triggered.emit(event)
        if self.capturing_data:
            return

        super().wheelEvent(event) 
Example 12
Project: urh   Author: jopohl   File: ScrollArea.py    License: GNU General Public License v3.0 5 votes vote down vote up
def wheelEvent(self, event: QWheelEvent):
        event.ignore() 
Example 13
Project: nanovna-saver   Author: NanoVNA-Saver   File: Frequency.py    License: GNU General Public License v3.0 4 votes vote down vote up
def wheelEvent(self, a0: QtGui.QWheelEvent) -> None:
        if len(self.data) == 0 and len(self.reference) == 0:
            a0.ignore()
            return
        do_zoom_x = do_zoom_y = True
        if a0.modifiers() == QtCore.Qt.ShiftModifier:
            do_zoom_x = False
        if a0.modifiers() == QtCore.Qt.ControlModifier:
            do_zoom_y = False
        if a0.angleDelta().y() > 0:
            # Zoom in
            a0.accept()
            # Center of zoom = a0.x(), a0.y()
            # We zoom in by 1/10 of the width/height.
            rate = a0.angleDelta().y() / 120
            if do_zoom_x:
                zoomx = rate * self.chartWidth / 10
            else:
                zoomx = 0
            if do_zoom_y:
                zoomy = rate * self.chartHeight / 10
            else:
                zoomy = 0
            absx = max(0, a0.x() - self.leftMargin)
            absy = max(0, a0.y() - self.topMargin)
            ratiox = absx/self.chartWidth
            ratioy = absy/self.chartHeight
            p1x = int(self.leftMargin + ratiox * zoomx)
            p1y = int(self.topMargin + ratioy * zoomy)
            p2x = int(self.leftMargin + self.chartWidth - (1 - ratiox) * zoomx)
            p2y = int(self.topMargin + self.chartHeight - (1 - ratioy) * zoomy)
            self.zoomTo(p1x, p1y, p2x, p2y)
        elif a0.angleDelta().y() < 0:
            # Zoom out
            a0.accept()
            # Center of zoom = a0.x(), a0.y()
            # We zoom out by 1/9 of the width/height, to match zoom in.
            rate = -a0.angleDelta().y() / 120
            if do_zoom_x:
                zoomx = rate * self.chartWidth / 9
            else:
                zoomx = 0
            if do_zoom_y:
                zoomy = rate * self.chartHeight / 9
            else:
                zoomy = 0
            absx = max(0, a0.x() - self.leftMargin)
            absy = max(0, a0.y() - self.topMargin)
            ratiox = absx/self.chartWidth
            ratioy = absy/self.chartHeight
            p1x = int(self.leftMargin - ratiox * zoomx)
            p1y = int(self.topMargin - ratioy * zoomy)
            p2x = int(self.leftMargin + self.chartWidth + (1 - ratiox) * zoomx)
            p2y = int(self.topMargin + self.chartHeight + (1 - ratioy) * zoomy)
            self.zoomTo(p1x, p1y, p2x, p2y)
        else:
            a0.ignore() 
Example 14
Project: nanovna-saver   Author: NanoVNA-Saver   File: TDR.py    License: GNU General Public License v3.0 4 votes vote down vote up
def wheelEvent(self, a0: QtGui.QWheelEvent) -> None:
        if len(self.tdrWindow.td) == 0:
            a0.ignore()
            return
        chart_height = self.chartHeight
        chart_width = self.chartWidth
        do_zoom_x = do_zoom_y = True
        if a0.modifiers() == QtCore.Qt.ShiftModifier:
            do_zoom_x = False
        if a0.modifiers() == QtCore.Qt.ControlModifier:
            do_zoom_y = False
        if a0.angleDelta().y() > 0:
            # Zoom in
            a0.accept()
            # Center of zoom = a0.x(), a0.y()
            # We zoom in by 1/10 of the width/height.
            rate = a0.angleDelta().y() / 120
            if do_zoom_x:
                zoomx = rate * chart_width / 10
            else:
                zoomx = 0
            if do_zoom_y:
                zoomy = rate * chart_height / 10
            else:
                zoomy = 0
            absx = max(0, a0.x() - self.leftMargin)
            absy = max(0, a0.y() - self.topMargin)
            ratiox = absx/chart_width
            ratioy = absy/chart_height
            # TODO: Change zoom to center on the mouse if possible,
            #       or extend box to the side that has room if not.
            p1x = int(self.leftMargin + ratiox * zoomx)
            p1y = int(self.topMargin + ratioy * zoomy)
            p2x = int(self.leftMargin + chart_width - (1 - ratiox) * zoomx)
            p2y = int(self.topMargin + chart_height - (1 - ratioy) * zoomy)
            self.zoomTo(p1x, p1y, p2x, p2y)
        elif a0.angleDelta().y() < 0:
            # Zoom out
            a0.accept()
            # Center of zoom = a0.x(), a0.y()
            # We zoom out by 1/9 of the width/height, to match zoom in.
            rate = -a0.angleDelta().y() / 120
            if do_zoom_x:
                zoomx = rate * chart_width / 9
            else:
                zoomx = 0
            if do_zoom_y:
                zoomy = rate * chart_height / 9
            else:
                zoomy = 0
            absx = max(0, a0.x() - self.leftMargin)
            absy = max(0, a0.y() - self.topMargin)
            ratiox = absx/chart_width
            ratioy = absy/chart_height
            p1x = int(self.leftMargin - ratiox * zoomx)
            p1y = int(self.topMargin - ratioy * zoomy)
            p2x = int(self.leftMargin + chart_width + (1 - ratiox) * zoomx)
            p2y = int(self.topMargin + chart_height + (1 - ratioy) * zoomy)
            self.zoomTo(p1x, p1y, p2x, p2y)
        else:
            a0.ignore()