def get_scroll_info(event):
    """
    Returns the (degrees, direction) of a scroll motion Qt event.
    """

    # 15 deg is standard 1-click turn for a wheel mouse
    # delta() usually returns 120
    if have_pyqt5:
        # TODO: use pixelDelta() for better handling on hi-res devices?
        point = event.angleDelta()
        dx, dy = point.x(), point.y()
        delta = math.sqrt(dx ** 2 + dy ** 2)
        if dy < 0:
            delta = -delta

        ang_rad = math.atan2(dy, dx)
        direction = math.degrees(ang_rad) - 90.0
        direction = math.fmod(direction + 360.0, 360.0)

    else:
        delta = event.delta()
        orientation = event.orientation()

        direction = None
        if orientation == QtCore.Qt.Horizontal:
            if delta > 0:
                direction = 270.0
            elif delta < 0:
                direction = 90.0
        else:
            if delta > 0:
                direction = 0.0
            elif delta < 0:
                direction = 180.0

    num_degrees = abs(delta) / 8.0

    return (num_degrees, direction)
def get_scroll_info ( event ) : if have_pyqt5 : point = event . angleDelta ( ) dx , dy = point . x ( ) , point . y ( ) delta = math . sqrt ( dx ** 2 + dy ** 2 ) if dy < 0 : delta = - delta ang_rad = math . atan2 ( dy , dx ) direction = math . degrees ( ang_rad ) - 90.0 direction = math . fmod ( direction + 360.0 , 360.0 ) else : delta = event . delta ( ) orientation = event . orientation ( ) direction = None if orientation == QtCore . Qt . Horizontal : if delta > 0 : direction = 270.0 elif delta < 0 : direction = 90.0 else : if delta > 0 : direction = 0.0 elif delta < 0 : direction = 180.0 num_degrees = abs ( delta ) / 8.0 return ( num_degrees , direction )
Returns the (degrees, direction) of a scroll motion Qt event.