Gtk.PopoverMenu

g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Bin Gtk.Bin Gtk.Popover Gtk.Popover Gtk.Bin->Gtk.Popover Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.PopoverMenu Gtk.PopoverMenu Gtk.Popover->Gtk.PopoverMenu Gtk.Widget->Gtk.Container

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

new ()

open_submenu (name)

Virtual Methods

Inherited:

Gtk.Popover (1), Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10)

Properties

Inherited:

Gtk.Popover (6), Gtk.Container (3), Gtk.Widget (39)

Name

Type

Flags

Short Description

visible-submenu

str

r/w

The name of the visible submenu

Child Properties

Name

Type

Default

Flags

Short Description

position

int

0

r/w

The index of the child in the parent

submenu

str

None

r/w

The name of the submenu

Style Properties

Inherited:

Gtk.Widget (17)

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:

Gtk.Popover

Abstract:

No

Structure:

Gtk.PopoverMenuClass

Gtk.PopoverMenu is a subclass of Gtk.Popover that treats its children 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 Gtk.Scale. In this respect, Gtk.PopoverMenu is more flexible than popovers that are created from a Gio.MenuModel 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 Gtk.ModelButton :inverted and Gtk.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:

Gtk.Widget

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 the Gtk.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.

Property Details

Gtk.PopoverMenu.props.visible_submenu
Name:

visible-submenu

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The name of the visible submenu