Adw.ButtonContent¶
- 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 |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Adw.ButtonContent(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A helper widget for creating buttons.
<picture> <source srcset=”button-content-dark.png” media=”(prefers-color-scheme: dark)”> <img src=”button-content.png” alt=”button-content”> </picture>
AdwButtonContent
is a box-like widget with an icon and a label.It’s intended to be used as a direct child of [class`Gtk`.Button], [class`Gtk`.MenuButton] or [class`SplitButton`], when they need to have both an icon and a label, as follows:
``xml <object class=”GtkButton”>
- <property name=”child”>
- <object class=”AdwButtonContent”>
<property name=”icon-name”>document-open-symbolic</property> <property name=”label” translatable=”yes”>_Open</property> <property name=”use-underline”>True</property>
</object>
</property>
</object> ``
AdwButtonContent
handles style classes and connecting the mnemonic to the button automatically.- CSS nodes
`` buttoncontent ╰── box
├── image ╰── label
AdwButtonContent
’s CSS node is calledbuttoncontent
. It contains abox
subnode that serves as a container for theimage
andlabel
nodes.When inside a
GtkButton
orAdwSplitButton
, the button will receive the.image-text-button
style class. When inside aGtkMenuButton
, the internalGtkButton
will receive it instead.- Accessibility
AdwButtonContent
uses theGTK_ACCESSIBLE_ROLE_GROUP
role.- classmethod new()¶
- Returns:
the new created
AdwButtonContent
- Return type:
Creates a new
AdwButtonContent
.
- get_can_shrink()¶
- Returns:
whether the button can shrink
- Return type:
gets whether the button can be smaller than the natural size of its contents.
New in version 1.4.
- get_use_underline()¶
- Returns:
whether an underline in the text indicates a mnemonic
- Return type:
Gets whether an underline in the text indicates a mnemonic.
- set_can_shrink(can_shrink)¶
- Parameters:
can_shrink (
bool
) – whether the button can shrink
Sets whether the button can be smaller than the natural size of its contents.
If set to
TRUE
, the label will ellipsize.See [method`Gtk`.Button.set_can_shrink].
New in version 1.4.
- set_icon_name(icon_name)¶
- Parameters:
icon_name (
str
) – the new icon name
Sets the name of the displayed icon.
If empty, the icon is not shown.
- set_use_underline(use_underline)¶
- Parameters:
use_underline (
bool
) – whether an underline in the text indicates a mnemonic
Sets whether an underline in the text indicates a mnemonic.
The mnemonic can be used to activate the parent button.
See [property`ButtonContent`:py:data::label<Adw.ButtonContent.props.label>].
Property Details¶
- Adw.ButtonContent.props.can_shrink¶
- Name:
can-shrink
- Type:
- Default Value:
- Flags:
Whether the button can be smaller than the natural size of its contents.
If set to
TRUE
, the label will ellipsize.See [property`Gtk`.Button:can-shrink].
New in version 1.4.
- Adw.ButtonContent.props.icon_name¶
- Name:
icon-name
- Type:
- Default Value:
''
- Flags:
The name of the displayed icon.
If empty, the icon is not shown.
- Adw.ButtonContent.props.label¶
- Name:
label
- Type:
- Default Value:
''
- Flags:
The displayed label.
- Adw.ButtonContent.props.use_underline¶
- Name:
use-underline
- Type:
- Default Value:
- Flags:
Whether an underline in the text indicates a mnemonic.
The mnemonic can be used to activate the parent button.
See [property`ButtonContent`:py:data::label<Adw.ButtonContent.props.label>].