:right-sidebar: True Avatar =================================================================== .. currentmodule:: gi.repository.Adw .. class:: Avatar(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget` A widget displaying an image, with a generated fallback. .. image:: https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1-latest/avatar.png ``AdwAvatar`` is a widget that shows a round avatar. ``AdwAvatar`` generates an avatar with the initials of the :obj:`~gi.repository.Adw.Avatar.props.text` on top of a colored background. The color is picked based on the hash of the :obj:`~gi.repository.Adw.Avatar.props.text`\. If :obj:`~gi.repository.Adw.Avatar.props.show_initials` is set to ``FALSE``\, :obj:`~gi.repository.Adw.Avatar.props.icon_name` or ``avatar-default-symbolic`` is shown instead of the initials. Use :obj:`~gi.repository.Adw.Avatar.props.custom_image` to set a custom image. CSS nodes -------------------------------------------------------------------------------- ``AdwAvatar`` has a single CSS node with name ``avatar``\. Constructors ------------ .. rst-class:: interim-class .. class:: Avatar :no-index: .. classmethod:: new(size: int, text: str | None, show_initials: bool) -> ~gi.repository.Gtk.Widget Creates a new ``AdwAvatar``\. :param size: The size of the avatar :param text: the text used to get the initials and color :param show_initials: whether to use initials instead of an icon as fallback Methods ------- .. rst-class:: interim-class .. class:: Avatar :no-index: .. method:: draw_to_texture(scale_factor: int) -> ~gi.repository.Gdk.Texture Renders ``self`` into a :obj:`~gi.repository.Gdk.Texture` at ``scale_factor``\. This can be used to export the fallback avatar. :param scale_factor: The scale factor .. method:: get_custom_image() -> ~gi.repository.Gdk.Paintable | None Gets the custom image paintable. .. method:: get_icon_name() -> str | None Gets the name of an icon to use as a fallback. .. method:: get_show_initials() -> bool Gets whether initials are used instead of an icon on the fallback avatar. .. method:: get_size() -> int Gets the size of the avatar. .. method:: get_text() -> str | None Gets the text used to generate the fallback initials and color. .. method:: set_custom_image(custom_image: ~gi.repository.Gdk.Paintable | None = None) -> None Sets the custom image paintable. Custom image is displayed instead of initials or icon. :param custom_image: a custom image .. method:: 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. :param icon_name: the icon name .. method:: set_show_initials(show_initials: bool) -> None Sets whether to use initials instead of an icon on the fallback avatar. See :obj:`~gi.repository.Adw.Avatar.props.icon_name` for how to change the fallback icon. :param show_initials: whether to use initials instead of an icon as fallback .. method:: set_size(size: int) -> None Sets the size of the avatar. :param size: The size of the avatar .. method:: 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 :obj:`~gi.repository.Adw.Avatar.props.show_initials` is ``FALSE``\. :param text: the text used to get the initials and color Properties ---------- .. rst-class:: interim-class .. class:: Avatar :no-index: .. attribute:: props.custom_image :type: ~gi.repository.Gdk.Paintable The type of the None singleton. .. attribute:: props.icon_name :type: str The type of the None singleton. .. attribute:: props.show_initials :type: bool The type of the None singleton. .. attribute:: props.size :type: int The type of the None singleton. .. attribute:: props.text :type: str The type of the None singleton.