Gtk.PopoverMenu¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Popover (19), Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)
- Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
class |
|
|
Virtual Methods¶
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w |
The name of the visible submenu |
Child Properties¶
Name |
Type |
Default |
Flags |
Short Description |
---|---|---|---|---|
|
|
r/w |
The index of the child in the parent |
|
|
r/w |
The name of the submenu |
Style Properties¶
- Inherited:
Signals¶
- Inherited:
Gtk.Popover (1), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)
Fields¶
- Inherited:
Gtk.Popover (1), Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)
Class Details¶
- class Gtk.PopoverMenu(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Gtk.PopoverMenu
is a subclass ofGtk.Popover
that treats its children like menus and allows switching between them. It is meant to be used primarily together withGtk.ModelButton
, but any widget can be used, such asGtk.SpinButton
orGtk.Scale
. In this respect,Gtk.PopoverMenu
is more flexible than popovers that are created from aGio.MenuModel
withGtk.Popover.new_from_model
().To add a child as a submenu, set the
Gtk.PopoverMenu
:submenu
child property to the name of the submenu. To let the user open this submenu, add aGtk.ModelButton
whoseGtk.ModelButton
:menu-name
property is set to the name you’ve given to the submenu.By convention, the first child of a submenu should be a
Gtk.ModelButton
to switch back to the parent menu. Such a button should use theGtk.ModelButton
:inverted
andGtk.ModelButton
:centered
properties to achieve a title-like appearance and place the submenu indicator at the opposite side. To switch back to the main menu, use “main” as the menu name.- 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">win.frob</property> <property name="text" translatable="yes">Frob</property> </object> </child> <child> <object class="GtkModelButton"> <property name="visible">True</property> <property name="menu-name">more</property> <property name="text" translatable="yes">More</property> </object> </child> </object> </child> <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">win.foo</property> <property name="text" translatable="yes">Foo</property> </object> </child> <child> <object class="GtkModelButton"> <property name="visible">True</property> <property name="action-name">win.bar</property> <property name="text" translatable="yes">Bar</property> </object> </child> </object> <packing> <property name="submenu">more</property> </packing> </child> </object>
Just like normal popovers created using
Gtk.Popover.new_from_model
,Gtk.PopoverMenu
instances have a single css node called “popover” and get the .menu style class.- classmethod new()[source]¶
- Returns:
a new
Gtk.PopoverMenu
- Return type:
Creates a new popover menu.
New in version 3.16.
- open_submenu(name)[source]¶
- Parameters:
name (
str
) – the name of the menu to switch to
Opens a submenu of the self. The name must be one of the names given to the submenus of self with
Gtk.PopoverMenu
:submenu
, or “main” to switch back to the main menu.Gtk.ModelButton
will open submenus automatically when theGtk.ModelButton
:menu-name
property is set, so this function is only needed when you are using other kinds of widgets to initiate menu changes.New in version 3.16.