Skip to content

Gtk.Accessible

interface

An interface for describing UI elements for Assistive Technologies.

Every accessible implementation has:

The role cannot be changed after instantiating a GtkAccessible implementation.

The attributes are updated every time a UI element's state changes in a way that should be reflected by assistive technologies. For instance, if a GtkWidget visibility changes, the AccessibleState.HIDDEN state will also change to reflect the Widget.visible property.

Every accessible implementation is part of a tree of accessible objects. Normally, this tree corresponds to the widget tree, but can be customized by reimplementing the Accessible.get_accessible_parent, Accessible.get_first_accessible_child and Accessible.get_next_accessible_sibling virtual functions.

Note that you can not create a top-level accessible object as of now, which means that you must always have a parent accessible object.

Also note that when an accessible object does not correspond to a widget, and it has children, whose implementation you don't control, it is necessary to ensure the correct shape of the a11y tree by calling Accessible.set_accessible_parent and updating the sibling by Accessible.update_next_accessible_sibling.

Methods

announce

def announce(self, message: str, priority: AccessibleAnnouncementPriority | int) -> None

Requests the user's screen reader to announce the given message.

This kind of notification is useful for messages that either have only a visual representation or that are not exposed visually at all, e.g. a notification about a successful operation.

Also, by using this API, you can ensure that the message does not interrupts the user's current screen reader output.

Parameters:

  • message — the string to announce
  • priority — the priority of the announcement

get_accessible_id

def get_accessible_id(self) -> str | None

Retrieves the accessible identifier for the accessible object.

This functionality can be overridden by GtkAccessible implementations.

It is left to the accessible implementation to define the scope and uniqueness of the identifier.

get_accessible_parent

def get_accessible_parent(self) -> Accessible | None

Retrieves the accessible parent for an accessible object.

This function returns NULL for top level widgets.

get_accessible_role

def get_accessible_role(self) -> AccessibleRole

Retrieves the accessible role of an accessible object.

get_at_context

def get_at_context(self) -> ATContext

Retrieves the implementation for the given accessible object.

get_bounds

def get_bounds(self) -> tuple[bool, int, int, int, int]

Queries the coordinates and dimensions of this accessible

This functionality can be overridden by GtkAccessible implementations, e.g. to get the bounds from an ignored child widget.

get_first_accessible_child

def get_first_accessible_child(self) -> Accessible | None

Retrieves the first accessible child of an accessible object.

get_next_accessible_sibling

def get_next_accessible_sibling(self) -> Accessible | None

Retrieves the next accessible sibling of an accessible object

get_platform_state

def get_platform_state(self, state: AccessiblePlatformState | int) -> bool

Queries a platform state, such as focus.

This functionality can be overridden by GtkAccessible implementations, e.g. to get platform state from an ignored child widget, as is the case for GtkText wrappers.

Parameters:

  • state — platform state to query

reset_property

def reset_property(self, property: AccessibleProperty | int) -> None

Resets the accessible property to its default value.

Parameters:

  • property — the accessible property

reset_relation

def reset_relation(self, relation: AccessibleRelation | int) -> None

Resets the accessible relation to its default value.

Parameters:

  • relation — the accessible relation

reset_state

def reset_state(self, state: AccessibleState | int) -> None

Resets the accessible state to its default value.

Parameters:

  • state — the accessible state

set_accessible_parent

def set_accessible_parent(self, parent: Accessible | None = ..., next_sibling: Accessible | None = ...) -> None

Sets the parent and sibling of an accessible object.

This function is meant to be used by accessible implementations that are not part of the widget hierarchy, and but act as a logical bridge between widgets. For instance, if a widget creates an object that holds metadata for each child, and you want that object to implement the GtkAccessible interface, you will use this function to ensure that the parent of each child widget is the metadata object, and the parent of each metadata object is the container widget.

Parameters:

  • parent — the parent accessible object
  • next_sibling — the sibling accessible object

update_next_accessible_sibling

def update_next_accessible_sibling(self, new_sibling: Accessible | None = ...) -> None

Updates the next accessible sibling.

That might be useful when a new child of a custom accessible is created, and it needs to be linked to a previous child.

Parameters:

  • new_sibling — the new next accessible sibling to set

update_platform_state

def update_platform_state(self, state: AccessiblePlatformState | int) -> None

Informs ATs that the platform state has changed.

This function should be used by GtkAccessible implementations that have a platform state but are not widgets. Widgets handle platform states automatically.

Parameters:

  • state — the platform state to update

update_property

def update_property(self, properties: list[AccessibleProperty | int], values: list[GObject.Value]) -> None

Updates an array of accessible properties.

This function should be called by GtkWidget types whenever an accessible property change must be communicated to assistive technologies.

This function is meant to be used by language bindings.

Parameters:

  • properties — an array of accessible properties
  • values — an array of GValues, one for each property

update_relation

def update_relation(self, relations: list[AccessibleRelation | int], values: list[GObject.Value]) -> None

Updates an array of accessible relations.

This function should be called by GtkWidget types whenever an accessible relation change must be communicated to assistive technologies.

This function is meant to be used by language bindings.

Parameters:

  • relations — an array of accessible relations
  • values — an array of GValues, one for each relation

update_state

def update_state(self, states: list[AccessibleState | int], values: list[GObject.Value]) -> None

Updates an array of accessible states.

This function should be called by GtkWidget types whenever an accessible state change must be communicated to assistive technologies.

This function is meant to be used by language bindings.

Parameters:

  • states — an array of accessible states
  • values — an array of GValues, one for each state

Virtual methods

do_get_accessible_id

def do_get_accessible_id(self) -> str | None

Retrieves the accessible identifier for the accessible object.

This functionality can be overridden by GtkAccessible implementations.

It is left to the accessible implementation to define the scope and uniqueness of the identifier.

do_get_accessible_parent

def do_get_accessible_parent(self) -> Accessible | None

Retrieves the accessible parent for an accessible object.

This function returns NULL for top level widgets.

do_get_at_context

def do_get_at_context(self) -> ATContext | None

Retrieves the implementation for the given accessible object.

do_get_bounds

def do_get_bounds(self) -> tuple[bool, int, int, int, int]

Queries the coordinates and dimensions of this accessible

This functionality can be overridden by GtkAccessible implementations, e.g. to get the bounds from an ignored child widget.

do_get_first_accessible_child

def do_get_first_accessible_child(self) -> Accessible | None

Retrieves the first accessible child of an accessible object.

do_get_next_accessible_sibling

def do_get_next_accessible_sibling(self) -> Accessible | None

Retrieves the next accessible sibling of an accessible object

do_get_platform_state

def do_get_platform_state(self, state: AccessiblePlatformState | int) -> bool

Queries a platform state, such as focus.

This functionality can be overridden by GtkAccessible implementations, e.g. to get platform state from an ignored child widget, as is the case for GtkText wrappers.

Parameters:

  • state — platform state to query

Properties

accessible_role

accessible_role: AccessibleRole | int  # read/write

The accessible role of the given GtkAccessible implementation.

The accessible role cannot be changed once set.