Skip to content

Gtk.Native

interface

An interface for widgets that have their own Gdk.Surface.

The obvious example of a GtkNative is GtkWindow.

Every widget that is not itself a GtkNative is contained in one, and you can get it with Widget.get_native.

To get the surface of a GtkNative, use Native.get_surface. It is also possible to find the GtkNative to which a surface belongs, with Native.get_for_surface.

In addition to a Gdk.Surface, a GtkNative also provides a Gsk.Renderer for rendering on that surface. To get the renderer, use Native.get_renderer.

Methods

get_renderer

def get_renderer(self) -> Gsk.Renderer | None

Returns the renderer that is used for this GtkNative.

get_surface

def get_surface(self) -> Gdk.Surface | None

Returns the surface of this GtkNative.

get_surface_transform

def get_surface_transform(self) -> tuple[float, float]

Retrieves the surface transform of self.

This is the translation from self's surface coordinates into self's widget coordinates.

realize

def realize(self) -> None

Realizes a GtkNative.

This should only be used by subclasses.

unrealize

def unrealize(self) -> None

Unrealizes a GtkNative.

This should only be used by subclasses.

Static functions

get_for_surface

@staticmethod
def get_for_surface(surface: Gdk.Surface) -> Native | None

Finds the GtkNative associated with the surface.

Parameters:

  • surface — a GdkSurface