Skip to content

Gtk.Root

interface

An interface for widgets that can act as the root of a widget hierarchy.

The root widget takes care of providing the connection to the windowing system and manages layout, drawing and event delivery for its widget hierarchy.

The obvious example of a GtkRoot is GtkWindow.

To get the display to which a GtkRoot belongs, use Root.get_display.

GtkRoot also maintains the location of keyboard focus inside its widget hierarchy, with Root.set_focus and Root.get_focus.

Methods

get_display

def get_display(self) -> Gdk.Display

Returns the display that this GtkRoot is on.

get_focus

def get_focus(self) -> Widget | None

Retrieves the current focused widget within the root.

Note that this is the widget that would have the focus if the root is active; if the root is not focused then gtk_widget_has_focus (widget) will be False for the widget.

set_focus

def set_focus(self, focus: Widget | None = ...) -> None

If focus is not the current focus widget, and is focusable, sets it as the focus widget for the root.

If focus is None, unsets the focus widget for the root.

To set the focus to a particular widget in the root, it is usually more convenient to use Widget.grab_focus instead of this function.

Parameters:

  • focus — widget to be the new focus widget, or None to unset the focus widget