Gtk.ModelButton¶
Subclasses: | None |
---|
Methods¶
class | new () |
Virtual Methods¶
Inherited: | Gtk.Button (6), Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gtk.Actionable (4), Gtk.Activatable (2) |
---|
Properties¶
Inherited: | Gtk.Button (9), Gtk.Container (3), Gtk.Widget (39), Gtk.Actionable (2), Gtk.Activatable (2) |
---|
Name | Type | Flags | Short Description |
---|---|---|---|
active |
bool |
r/w/en | Active |
centered |
bool |
r/w/en | Whether to center the contents |
icon |
Gio.Icon |
r/w/en | The icon |
iconic |
bool |
r/w/en | Whether to prefer the icon over text |
inverted |
bool |
r/w/en | Whether the menu is a parent |
menu-name |
str |
r/w/en | The name of the menu to open |
role |
Gtk.ButtonRole |
r/w/en | The role of this button |
text |
str |
r/w/en | The text |
use-markup |
bool |
r/w/en | The text of the button includes XML markup. See Pango.parse_markup () |
Style Properties¶
Inherited: | Gtk.Button (7), Gtk.Widget (17) |
---|
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: Gtk.Button
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
widgetReturn type: Gtk.Widget
Creates a new
Gtk.ModelButton
.New in version 3.16.
Property Details¶
-
Gtk.ModelButton.props.
active
¶ Name: active
Type: bool
Default Value: False
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
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: bool
Default Value: False
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
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: Gio.Icon
Default Value: None
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
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: bool
Default Value: False
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
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: bool
Default Value: False
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
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.
Name: menu-name
Type: str
Default Value: None
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
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: Gtk.ButtonRole
Default Value: Gtk.ButtonRole.NORMAL
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
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: str
Default Value: ''
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
The label for the button.
New in version 3.16.
-
Gtk.ModelButton.props.
use_markup
¶ Name: use-markup
Type: bool
Default Value: False
Flags: READABLE
,WRITABLE
,EXPLICIT_NOTIFY
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.