Adw.Avatar¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Adw.Avatar(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A widget displaying an image, with a generated fallback.
<picture> <source srcset=”avatar-dark.png” media=”(prefers-color-scheme: dark)”> <img src=”avatar.png” alt=”avatar”> </picture>
AdwAvatar
is a widget that shows a round avatar.AdwAvatar
generates an avatar with the initials of the [property`Avatar`:py:data::text<Adw.Avatar.props.text>] on top of a colored background.The color is picked based on the hash of the [property`Avatar`:py:data::text<Adw.Avatar.props.text>].
If [property`Avatar`:py:data::show-initials<Adw.Avatar.props.show_initials>] is set to
FALSE
, [property`Avatar`:py:data::icon-name<Adw.Avatar.props.icon_name>] oravatar-default-symbolic
is shown instead of the initials.Use [property`Avatar`:py:data::custom-image<Adw.Avatar.props.custom_image>] to set a custom image.
- CSS nodes
AdwAvatar
has a single CSS node with nameavatar
.- classmethod new(size, text, show_initials)¶
- Parameters:
- Returns:
the newly created
AdwAvatar
- Return type:
Creates a new
AdwAvatar
.
- draw_to_texture(scale_factor)¶
- Parameters:
scale_factor (
int
) – The scale factor- Returns:
the texture
- Return type:
Renders self into a [class`Gdk`.Texture] at scale_factor.
This can be used to export the fallback avatar.
- get_custom_image()¶
- Returns:
the custom image
- Return type:
Gets the custom image paintable.
- get_icon_name()¶
-
Gets the name of an icon to use as a fallback.
- get_show_initials()¶
- Returns:
whether initials are used instead of an icon as fallback
- Return type:
Gets whether initials are used instead of an icon on the fallback avatar.
- get_text()¶
-
Gets the text used to generate the fallback initials and color.
- set_custom_image(custom_image)¶
- Parameters:
custom_image (
Gdk.Paintable
orNone
) – a custom image
Sets the custom image paintable.
Custom image is displayed instead of initials or icon.
- set_icon_name(icon_name)¶
-
Sets the name of an icon to use as a fallback.
If no name is set,
avatar-default-symbolic
will be used.
- set_show_initials(show_initials)¶
- Parameters:
show_initials (
bool
) – whether to use initials instead of an icon as fallback
Sets whether to use initials instead of an icon on the fallback avatar.
See [property`Avatar`:py:data::icon-name<Adw.Avatar.props.icon_name>] for how to change the fallback icon.
Property Details¶
- Adw.Avatar.props.custom_image¶
- Name:
custom-image
- Type:
- Default Value:
- Flags:
A custom image paintable.
Custom image is displayed instead of initials or icon.
- Adw.Avatar.props.icon_name¶
- Name:
icon-name
- Type:
- Default Value:
- Flags:
The name of an icon to use as a fallback.
If no name is set,
avatar-default-symbolic
will be used.
- Adw.Avatar.props.show_initials¶
- Name:
show-initials
- Type:
- Default Value:
- Flags:
Whether initials are used instead of an icon on the fallback avatar.
See [property`Avatar`:py:data::icon-name<Adw.Avatar.props.icon_name>] for how to change the fallback icon.
- Adw.Avatar.props.size¶
- Name:
size
- Type:
- Default Value:
-1
- Flags:
The size of the avatar.
- Adw.Avatar.props.text¶
- Name:
text
- Type:
- Default Value:
''
- Flags:
Sets the text used to generate the fallback initials and color.
It’s only used to generate the color if [property`Avatar`:py:data::show-initials<Adw.Avatar.props.show_initials>] is
FALSE
.