:right-sidebar: True PopoverMenu =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: PopoverMenu(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Popover`, :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`, :class:`~gi.repository.Gtk.Native`, :class:`~gi.repository.Gtk.ShortcutManager` :Constructors: :: PopoverMenu(**properties) new_from_model(model:Gio.MenuModel=None) -> Gtk.Widget new_from_model_full(model:Gio.MenuModel, flags:Gtk.PopoverMenuFlags) -> Gtk.Widget Constructors ------------ .. rst-class:: interim-class .. class:: PopoverMenu :no-index: .. classmethod:: new_from_model(model: ~gi.repository.Gio.MenuModel | None = None) -> ~gi.repository.Gtk.Widget Creates a ``GtkPopoverMenu`` and populates it according to ``model``. The created buttons are connected to actions found in the ``GtkApplicationWindow`` to which the popover belongs - typically by means of being attached to a widget that is contained within the ``GtkApplicationWindow``'s widget hierarchy. Actions can also be added using :obj:`~gi.repository.Gtk.Widget.insert_action_group` on the menus attach widget or on any of its parent widgets. This function creates menus with sliding submenus. See :obj:`~gi.repository.Gtk.PopoverMenu.new_from_model_full` for a way to control this. :param model: a ``GMenuModel`` .. classmethod:: new_from_model_full(model: ~gi.repository.Gio.MenuModel, flags: ~gi.repository.Gtk.PopoverMenuFlags) -> ~gi.repository.Gtk.Widget Creates a ``GtkPopoverMenu`` and populates it according to ``model``. The created buttons are connected to actions found in the action groups that are accessible from the parent widget. This includes the ``GtkApplicationWindow`` to which the popover belongs. Actions can also be added using :obj:`~gi.repository.Gtk.Widget.insert_action_group` on the parent widget or on any of its parent widgets. :param model: a ``GMenuModel`` :param flags: flags that affect how the menu is created Methods ------- .. rst-class:: interim-class .. class:: PopoverMenu :no-index: .. method:: add_child(child: ~gi.repository.Gtk.Widget, id: str) -> bool Adds a custom widget to a generated menu. For this to work, the menu model of ``popover`` 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_flags() -> ~gi.repository.Gtk.PopoverMenuFlags Returns the flags that ``popover`` uses to create/display a menu from its model. .. versionadded:: 4.14 .. method:: get_menu_model() -> ~gi.repository.Gio.MenuModel | None Returns the menu model used to populate the popover. .. method:: remove_child(child: ~gi.repository.Gtk.Widget) -> bool Removes a widget that has previously been added with :obj:`~gi.repository.Gtk.PopoverMenu.add_child()` :param child: the ``GtkWidget`` to remove .. method:: set_flags(flags: ~gi.repository.Gtk.PopoverMenuFlags) -> None Sets the flags that ``popover`` uses to create/display a menu from its model. If a model is set and the flags change, contents are rebuilt, so if setting properties individually, set flags before model to avoid a redundant rebuild. .. versionadded:: 4.14 :param flags: a set of ``GtkPopoverMenuFlags`` .. method:: set_menu_model(model: ~gi.repository.Gio.MenuModel | None = None) -> None Sets a new menu model on ``popover``. The existing contents of ``popover`` are removed, and the ``popover`` is populated with new contents according to ``model``. :param model: a ``GMenuModel`` Properties ---------- .. rst-class:: interim-class .. class:: PopoverMenu :no-index: .. attribute:: props.flags :type: ~gi.repository.Gtk.PopoverMenuFlags The flags that ``popover`` uses to create/display a menu from its model. If a model is set and the flags change, contents are rebuilt, so if setting properties individually, set flags before model to avoid a redundant rebuild. .. versionadded:: 4.14 .. attribute:: props.menu_model :type: ~gi.repository.Gio.MenuModel The model from which the menu is made. .. attribute:: props.visible_submenu :type: str The name of the visible submenu.