Gtk.Accessible¶
interface
An interface for describing UI elements for Assistive Technologies.
Every accessible implementation has:
- a “role”, represented by a value of the
AccessibleRoleenumeration - “attributes”, represented by a set of
AccessibleState,AccessiblePropertyandAccessibleRelationvalues
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¶
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 announcepriority— the priority of the announcement
get_accessible_id¶
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¶
Retrieves the accessible parent for an accessible object.
This function returns NULL for top level widgets.
get_accessible_role¶
Retrieves the accessible role of an accessible object.
get_at_context¶
Retrieves the implementation for the given accessible object.
get_bounds¶
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¶
Retrieves the first accessible child of an accessible object.
get_next_accessible_sibling¶
Retrieves the next accessible sibling of an accessible object
get_platform_state¶
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¶
Resets the accessible property to its default value.
Parameters:
property— the accessible property
reset_relation¶
Resets the accessible relation to its default value.
Parameters:
relation— the accessible relation
reset_state¶
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 objectnext_sibling— the sibling accessible object
update_next_accessible_sibling¶
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¶
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 propertiesvalues— an array ofGValues, 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 relationsvalues— an array ofGValues, one for each relation
update_state¶
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 statesvalues— an array ofGValues, one for each state
Virtual methods¶
do_get_accessible_id¶
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¶
Retrieves the accessible parent for an accessible object.
This function returns NULL for top level widgets.
do_get_at_context¶
Retrieves the implementation for the given accessible object.
do_get_bounds¶
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¶
Retrieves the first accessible child of an accessible object.
do_get_next_accessible_sibling¶
Retrieves the next accessible sibling of an accessible object
do_get_platform_state¶
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¶
The accessible role of the given GtkAccessible implementation.
The accessible role cannot be changed once set.