:right-sidebar: True PopoverMenuBar =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: PopoverMenuBar(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget` ``GtkPopoverMenuBar`` presents a horizontal bar of items that pop up popover menus when clicked. .. image:: https://docs.gtk.org/gtk4/menubar.png The only way to create instances of ``GtkPopoverMenuBar`` is from a ``GMenuModel``\. CSS nodes -------------------------------------------------------------------------------- .. code-block:: :dedent: 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 :const:`~gi.repository.Gtk.AccessibleRole.MENU_BAR` role, the menu items use the :const:`~gi.repository.Gtk.AccessibleRole.MENU_ITEM` role and the menus use the :const:`~gi.repository.Gtk.AccessibleRole.MENU` role. Constructors ------------ .. rst-class:: interim-class .. class:: PopoverMenuBar :no-index: .. classmethod:: new_from_model(model: ~gi.repository.Gio.MenuModel | None = None) -> ~gi.repository.Gtk.Widget Creates a ``GtkPopoverMenuBar`` from a ``GMenuModel``\. :param model: a ``GMenuModel`` Methods ------- .. rst-class:: interim-class .. class:: PopoverMenuBar :no-index: .. method:: add_child(child: ~gi.repository.Gtk.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``\. :param child: the ``GtkWidget`` to add :param id: the ID to insert ``child`` at .. method:: get_menu_model() -> ~gi.repository.Gio.MenuModel | None Returns the model from which the contents of ``bar`` are taken. .. method:: remove_child(child: ~gi.repository.Gtk.Widget) -> bool Removes a widget that has previously been added with :func:`~gi.repository.Gtk.PopoverMenuBar.add_child`. :param child: the ``GtkWidget`` to remove .. method:: set_menu_model(model: ~gi.repository.Gio.MenuModel | None = None) -> None Sets a menu model from which ``bar`` should take its contents. :param model: a ``GMenuModel`` Properties ---------- .. rst-class:: interim-class .. class:: PopoverMenuBar :no-index: .. attribute:: props.menu_model :type: ~gi.repository.Gio.MenuModel The type of the None singleton.