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.PopoverMenuis a subclass ofGtk.Popoverthat 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.SpinButtonorGtk.Scale. In this respect,Gtk.PopoverMenuis more flexible than popovers that are created from aGio.MenuModelwithGtk.Popover.new_from_model().To add a child as a submenu, set the
Gtk.PopoverMenu:submenuchild property to the name of the submenu. To let the user open this submenu, add aGtk.ModelButtonwhoseGtk.ModelButton:menu-nameproperty is set to the name you’ve given to the submenu.By convention, the first child of a submenu should be a
Gtk.ModelButtonto switch back to the parent menu. Such a button should use theGtk.ModelButton:invertedandGtk.ModelButton:centeredproperties 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.PopoverMenuinstances 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.ModelButtonwill open submenus automatically when theGtk.ModelButton:menu-nameproperty 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.