Gtk.ModelButton¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Button (29), Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Actionable (5), Gtk.Activatable (6)
- Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
class |
|
Virtual Methods¶
Properties¶
- Inherited:
Gtk.Button (9), Gtk.Container (3), Gtk.Widget (39), Gtk.Actionable (2), Gtk.Activatable (2)
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
Active |
||
r/w/en |
Whether to center the contents |
||
r/w/en |
The icon |
||
r/w/en |
Whether to prefer the icon over text |
||
r/w/en |
Whether the menu is a parent |
||
r/w/en |
The name of the menu to open |
||
r/w/en |
The role of this button |
||
r/w/en |
The text |
||
r/w/en |
The text of the button includes XML markup. See |
Style Properties¶
- Inherited:
Signals¶
- Inherited:
Gtk.Button (6), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)
Fields¶
- Inherited:
Gtk.Button (6), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)
Class Details¶
- class Gtk.ModelButton(*args, **kwargs)¶
- Bases:
- Abstract:
No
Gtk.ModelButton
is a button class that can use aGio.Action
as its model. In contrast toGtk.ToggleButton
orGtk.RadioButton
, which can also be backed by aGio.Action
via theGtk.Actionable
:action-name
property,Gtk.ModelButton
will adapt its appearance according to the kind of action it is backed by, and appear either as a plain, check or radio button.Model buttons are used when popovers from a menu model with
Gtk.Popover.new_from_model
(); they can also be used manually in aGtk.PopoverMenu
.When the action is specified via the
Gtk.Actionable
:action-name
andGtk.Actionable
:action-target
properties, the role of the button (i.e. whether it is a plain, check or radio button) is determined by the type of the action and doesn’t have to be explicitly specified with theGtk.ModelButton
:role
property.The content of the button is specified by the
Gtk.ModelButton
:text
andGtk.ModelButton
:icon
properties.The appearance of model buttons can be influenced with the
Gtk.ModelButton
:centered
andGtk.ModelButton
:iconic
properties.Model buttons have built-in support for submenus in
Gtk.PopoverMenu
. To make aGtk.ModelButton
that opens a submenu when activated, set theGtk.ModelButton
:menu-name
property. To make a button that goes back to the parent menu, you should set theGtk.ModelButton
:inverted
property to place the submenu indicator at the opposite side.- Example
<object class="GtkPopoverMenu"> <child> <object class="GtkBox"> <property name="visible">True</property> <property name="margin">10</property> <child> <object class="GtkModelButton"> <property name="visible">True</property> <property name="action-name">view.cut</property> <property name="text" translatable="yes">Cut</property> </object> </child> <child> <object class="GtkModelButton"> <property name="visible">True</property> <property name="action-name">view.copy</property> <property name="text" translatable="yes">Copy</property> </object> </child> <child> <object class="GtkModelButton"> <property name="visible">True</property> <property name="action-name">view.paste</property> <property name="text" translatable="yes">Paste</property> </object> </child> </object> </child> </object>
- CSS nodes
modelbutton ├── <child> ╰── check
modelbutton ├── <child> ╰── radio
modelbutton ├── <child> ╰── arrow
Gtk.ModelButton
has a main CSS node with name modelbutton, and a subnode, which will have the name check, radio or arrow, depending on the role of the button and whether it has a menu name set.The subnode is positioned before or after the content nodes and gets the .left or .right style class, depending on where it is located.
button.model ├── <child> ╰── check
Iconic model buttons (see
Gtk.ModelButton
:iconic
) change the name of their main node to button and add a .model style class to it. The indicator subnode is invisible in this case.- classmethod new()[source]¶
- Returns:
the newly created
Gtk.ModelButton
widget- Return type:
Creates a new
Gtk.ModelButton
.New in version 3.16.
Property Details¶
- Gtk.ModelButton.props.active¶
- Name:
active
- Type:
- Default Value:
- Flags:
The state of the button. This is reflecting the state of the associated
Gio.Action
.New in version 3.16.
- Gtk.ModelButton.props.centered¶
- Name:
centered
- Type:
- Default Value:
- Flags:
Whether to render the button contents centered instead of left-aligned. This property should be set for title-like items.
New in version 3.16.
- Gtk.ModelButton.props.icon¶
- Name:
icon
- Type:
- Default Value:
- Flags:
A
Gio.Icon
that will be used if iconic appearance for the button is desired.New in version 3.16.
- Gtk.ModelButton.props.iconic¶
- Name:
iconic
- Type:
- Default Value:
- Flags:
If this property is set, the button will show an icon if one is set. If no icon is set, the text will be used. This is typically used for horizontal sections of linked buttons.
New in version 3.16.
- Gtk.ModelButton.props.inverted¶
- Name:
inverted
- Type:
- Default Value:
- Flags:
Whether to show the submenu indicator at the opposite side than normal. This property should be set for model buttons that ‘go back’ to a parent menu.
New in version 3.16.
- Gtk.ModelButton.props.menu_name¶
- Name:
menu-name
- Type:
- Default Value:
- Flags:
The name of a submenu to open when the button is activated. If this is set, the button should not have an action associated with it.
New in version 3.16.
- Gtk.ModelButton.props.role¶
- Name:
role
- Type:
- Default Value:
- Flags:
Specifies whether the button is a plain, check or radio button. When
Gtk.Actionable
:action-name
is set, the role will be determined from the action and does not have to be set explicitly.New in version 3.16.
- Gtk.ModelButton.props.text¶
- Name:
text
- Type:
- Default Value:
''
- Flags:
The label for the button.
New in version 3.16.
- Gtk.ModelButton.props.use_markup¶
- Name:
use-markup
- Type:
- Default Value:
- Flags:
If
True
, XML tags in the text of the button are interpreted as byPango.parse_markup
() to format the enclosed spans of text. IfFalse
, the text will be displayed verbatim.New in version 3.24.