PopoverMenuBar

class PopoverMenuBar(**properties: Any)

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ConstraintTarget

GtkPopoverMenuBar presents a horizontal bar of items that pop up popover menus when clicked.

https://docs.gtk.org/gtk4/menubar.png

The only way to create instances of GtkPopoverMenuBar is from a GMenuModel.

CSS nodes

menubar
├── item[.active]
┊   ╰── popover
╰── item
    ╰── popover

GtkPopoverMenuBar has a single CSS node with name menubar, below which each item has its CSS node, and below that the corresponding popover.

The item whose popover is currently open gets the .active style class.

Accessibility

GtkPopoverMenuBar uses the MENU_BAR role, the menu items use the MENU_ITEM role and the menus use the MENU role.

Constructors

class PopoverMenuBar
classmethod new_from_model(model: MenuModel | None = None) Widget

Creates a GtkPopoverMenuBar from a GMenuModel.

Parameters:

model – a GMenuModel

Methods

class PopoverMenuBar
add_child(child: Widget, id: str) bool

Adds a custom widget to a generated menubar.

For this to work, the menu model of bar must have an item with a custom attribute that matches id.

Parameters:
  • child – the GtkWidget to add

  • id – the ID to insert child at

get_menu_model() MenuModel | None

Returns the model from which the contents of bar are taken.

remove_child(child: Widget) bool

Removes a widget that has previously been added with add_child().

Parameters:

child – the GtkWidget to remove

set_menu_model(model: MenuModel | None = None) None

Sets a menu model from which bar should take its contents.

Parameters:

model – a GMenuModel

Properties

class PopoverMenuBar
props.menu_model: MenuModel

The GMenuModel from which the menu bar is created.

The model should only contain submenus as toplevel elements.