Avatar#
Superclasses: Widget
, InitiallyUnowned
, Object
Implemented Interfaces: Accessible
, Buildable
, ConstraintTarget
A widget displaying an image, with a generated fallback.

AdwAvatar
is a widget that shows a round avatar.
AdwAvatar
generates an avatar with the initials of the
text
on top of a colored background.
The color is picked based on the hash of the text
.
If show_initials
is set to FALSE
,
icon_name
or avatar-default-symbolic
is shown instead of
the initials.
Use custom_image
to set a custom image.
CSS nodes#
AdwAvatar
has a single CSS node with name avatar
.
Constructors#
Methods#
- class Avatar
- draw_to_texture(scale_factor: int) Texture #
Renders
self
into aTexture
atscale_factor
.This can be used to export the fallback avatar.
- Parameters:
scale_factor – The scale factor
- get_show_initials() bool #
Gets whether initials are used instead of an icon on the fallback avatar.
- set_custom_image(custom_image: Paintable | None = None) None #
Sets the custom image paintable.
Custom image is displayed instead of initials or icon.
- Parameters:
custom_image – a custom image
- set_icon_name(icon_name: str | None = None) None #
Sets the name of an icon to use as a fallback.
If no name is set,
avatar-default-symbolic
will be used.- Parameters:
icon_name – the icon name
- set_show_initials(show_initials: bool) None #
Sets whether to use initials instead of an icon on the fallback avatar.
See
icon_name
for how to change the fallback icon.- Parameters:
show_initials – whether to use initials instead of an icon as fallback
- set_text(text: str | None = None) None #
Sets the text used to generate the fallback initials and color.
It’s only used to generate the color if
show_initials
isFALSE
.- Parameters:
text – the text used to get the initials and color