Accessible#
- class Accessible(*args, **kwargs)#
Implementations: AboutDialog, AccessibleHyperlink, ActionBar, AppChooserButton, AppChooserDialog, AppChooserWidget, ApplicationWindow, AspectFrame, Assistant, Box, Button, Calendar, CellView, CenterBox, CheckButton, ColorButton, ColorChooserDialog, ColorChooserWidget, ColorDialogButton, ColumnView, ComboBox, ComboBoxText, Dialog, DragIcon, DrawingArea, DropDown, EditableLabel, EmojiChooser, Entry, Expander, FileChooserDialog, FileChooserWidget, Fixed, FlowBox, FlowBoxChild, FontButton, FontChooserDialog, FontChooserWidget, FontDialogButton, Frame, GLArea, GraphicsOffload, Grid, GridView, HeaderBar, IconView, Image, InfoBar, Inscription, Label, LevelBar, LinkButton, ListBase, ListBox, ListBoxRow, ListView, LockButton, MediaControls, MenuButton, MessageDialog, Notebook, Overlay, PageSetupUnixDialog, Paned, PasswordEntry, Picture, Popover, PopoverBin, PopoverMenu, PopoverMenuBar, PrintUnixDialog, ProgressBar, Range, Revealer, Scale, ScaleButton, Scrollbar, ScrolledWindow, SearchBar, SearchEntry, Separator, ShortcutLabel, ShortcutsGroup, ShortcutsSection, ShortcutsShortcut, ShortcutsWindow, SpinButton, Spinner, Stack, StackPage, StackSidebar, StackSwitcher, Statusbar, Switch, Text, TextView, ToggleButton, TreeExpander, TreeView, Video, Viewport, VolumeButton, Widget, Window, WindowControls, WindowHandle
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
- “attributes”, represented by a set of
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 HIDDEN
state will also change to reflect the 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 get_accessible_parent,
get_first_accessible_child and
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 set_accessible_parent and
updating the sibling by update_next_accessible_sibling.
Methods#
- class Accessible
- announce(message: str, priority: AccessibleAnnouncementPriority) 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.
Added in version 4.14.
- Parameters:
message – the string to announce
priority – the priority of the announcement
- get_accessible_id() str | None#
Retrieves the accessible identifier for the accessible object.
This functionality can be overridden by
GtkAccessibleimplementations.It is left to the accessible implementation to define the scope and uniqueness of the identifier.
Added in version 4.22.
- get_accessible_parent() Accessible | None#
Retrieves the accessible parent for an accessible object.
This function returns
NULLfor top level widgets.Added in version 4.10.
- get_accessible_role() AccessibleRole#
Retrieves the accessible role of an accessible object.
- get_at_context() ATContext#
Retrieves the implementation for the given accessible object.
Added in version 4.10.
- get_bounds() tuple[bool, int, int, int, int]#
Queries the coordinates and dimensions of this accessible
This functionality can be overridden by
GtkAccessibleimplementations, e.g. to get the bounds from an ignored child widget.Added in version 4.10.
- get_first_accessible_child() Accessible | None#
Retrieves the first accessible child of an accessible object.
Added in version 4.10.
- get_next_accessible_sibling() Accessible | None#
Retrieves the next accessible sibling of an accessible object
Added in version 4.10.
- get_platform_state(state: AccessiblePlatformState) bool#
Queries a platform state, such as focus.
This functionality can be overridden by
GtkAccessibleimplementations, e.g. to get platform state from an ignored child widget, as is the case forGtkTextwrappers.Added in version 4.10.
- Parameters:
state – platform state to query
- reset_property(property: AccessibleProperty) None#
Resets the accessible property to its default value.
- Parameters:
property – the accessible property
- reset_relation(relation: AccessibleRelation) None#
Resets the accessible relation to its default value.
- Parameters:
relation – the accessible relation
- reset_state(state: AccessibleState) None#
Resets the accessible state to its default value.
- Parameters:
state – the accessible state
- set_accessible_parent(parent: Accessible | None = None, next_sibling: Accessible | None = 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
GtkAccessibleinterface, 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.Added in version 4.10.
- Parameters:
parent – the parent accessible object
next_sibling – the sibling accessible object
- update_next_accessible_sibling(new_sibling: Accessible | None = 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.
Added in version 4.10.
- Parameters:
new_sibling – the new next accessible sibling to set
- update_platform_state(state: AccessiblePlatformState) None#
Informs ATs that the platform state has changed.
This function should be used by
GtkAccessibleimplementations that have a platform state but are not widgets. Widgets handle platform states automatically.Added in version 4.18.
- Parameters:
state – the platform state to update
- update_property(properties: list[AccessibleProperty], values: list[Value]) None#
Updates a list of accessible properties.
See the
AccessiblePropertydocumentation for the value types of accessible properties.This function should be called by
GtkWidgettypes whenever an accessible property change must be communicated to assistive technologies.Example:
value = gtk_adjustment_get_value (adjustment); gtk_accessible_update_property (GTK_ACCESSIBLE (spin_button), GTK_ACCESSIBLE_PROPERTY_VALUE_NOW, value, -1);
- Parameters:
properties
values
- update_relation(relations: list[AccessibleRelation], values: list[Value]) None#
Updates a list of accessible relations.
This function should be called by
GtkWidgettypes whenever an accessible relation change must be communicated to assistive technologies.If the
AccessibleRelationrequires a list of references, you should pass each reference individually, followed byNULL, e.g.gtk_accessible_update_relation (accessible, GTK_ACCESSIBLE_RELATION_CONTROLS, ref1, NULL, GTK_ACCESSIBLE_RELATION_LABELLED_BY, ref1, ref2, ref3, NULL, -1);
- Parameters:
relations
values
- update_state(states: list[AccessibleState], values: list[Value]) None#
Updates a list of accessible states.
See the
AccessibleStatedocumentation for the value types of accessible states.This function should be called by
GtkWidgettypes whenever an accessible state change must be communicated to assistive technologies.Example:
value = GTK_ACCESSIBLE_TRISTATE_MIXED; gtk_accessible_update_state (GTK_ACCESSIBLE (check_button), GTK_ACCESSIBLE_STATE_CHECKED, value, -1);
- Parameters:
states
values
Properties#
- class Accessible
- props.accessible_role: AccessibleRole#
The accessible role of the given
GtkAccessibleimplementation.The accessible role cannot be changed once set.
Virtual Methods#
- class Accessible
- do_get_accessible_id() str | None#
Retrieves the accessible identifier for the accessible object.
This functionality can be overridden by
GtkAccessibleimplementations.It is left to the accessible implementation to define the scope and uniqueness of the identifier.
Added in version 4.22.
- do_get_accessible_parent() Accessible | None#
Retrieves the accessible parent for an accessible object.
This function returns
NULLfor top level widgets.Added in version 4.10.
- do_get_at_context() ATContext | None#
Retrieves the implementation for the given accessible object.
Added in version 4.10.
- do_get_bounds() tuple[bool, int, int, int, int]#
Queries the coordinates and dimensions of this accessible
This functionality can be overridden by
GtkAccessibleimplementations, e.g. to get the bounds from an ignored child widget.Added in version 4.10.
- do_get_first_accessible_child() Accessible | None#
Retrieves the first accessible child of an accessible object.
Added in version 4.10.
- do_get_next_accessible_sibling() Accessible | None#
Retrieves the next accessible sibling of an accessible object
Added in version 4.10.
- do_get_platform_state(state: AccessiblePlatformState) bool#
Queries a platform state, such as focus.
This functionality can be overridden by
GtkAccessibleimplementations, e.g. to get platform state from an ignored child widget, as is the case forGtkTextwrappers.Added in version 4.10.
- Parameters:
state – platform state to query