Skip to content

Gtk.GestureSwipe

class — extends GestureSingle

Recognizes swipe gestures.

After a press/move/.../move/release sequence happens, the GestureSwipe.swipe signal will be emitted, providing the velocity and directionality of the sequence at the time it was lifted.

If the velocity is desired in intermediate points, GestureSwipe.get_velocity can be called in a Gesture.update handler.

All velocities are reported in pixels/sec units.

Constructors

new

@classmethod
def new(cls) -> Gesture

Returns a newly created GtkGesture that recognizes swipes.

Methods

get_velocity

def get_velocity(self) -> tuple[bool, float, float]

Gets the current velocity.

If the gesture is recognized, this function returns True and fills in velocity_x and velocity_y with the recorded velocity, as per the last events processed.

Signals

swipe

def on_swipe(self, velocity_x: float, velocity_y: float) -> None: ...

Emitted when the recognized gesture is finished.

Velocity and direction are a product of previously recorded events.