Gtk.PopoverMenu
Gtk.PopoverMenu — Popovers to use as menus
Object Hierarchy:
GObject
╰── GInitiallyUnowned
╰── Gtk.Widget
╰── Gtk.Container
╰── Gtk.Bin
╰── Gtk.Popover
╰── Gtk.PopoverMenu
Functions:
- new
() -> Gtk.Widget
- open_submenu
(self, name:str)
Description:
Gtk.PopoverMenu
is a subclass of GtkPopover that treats its childen like menus and allows switching between them. It is meant to be used primarily together with Gtk.ModelButton, but any widget can be used, such as Gtk.SpinButton or GtkScale.
In this respect, Gtk.PopoverMenu
is more flexible than popovers that are created from a #GMenuModel with Gtk.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 a Gtk.ModelButton whose Gtk.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 the 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.
Glade UI 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>
Function Details:
new()
new () -> Gtk.Widget
Creates a new popover menu.
Returns: a new Gtk.PopoverMenu
Since: 3.16
open_submenu()
open_submenu (self, name:str)
Opens a submenu of the popover
. The name
must be one of the names given to the submenusof popover
with “submenu”, or"main" to switch back to the main menu.
Gtk.ModelButton
will open submenus automaticallywhen the “menu-name” property is set,so this function is only needed when you are usingother kinds of widgets to initiate menu changes.
- Since: 3.16