:right-sidebar: True Popover =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: Popover(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gtk.EmojiChooser`, :class:`~gi.repository.Gtk.PopoverMenu` 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: :: Popover(**properties) new() -> Gtk.Widget Constructors ------------ .. rst-class:: interim-class .. class:: Popover :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.Widget Creates a new ``GtkPopover``. Methods ------- .. rst-class:: interim-class .. class:: Popover :no-index: .. method:: get_autohide() -> bool Returns whether the popover is modal. See :obj:`~gi.repository.Gtk.Popover.set_autohide` for the implications of this. .. method:: get_cascade_popdown() -> bool Returns whether the popover will close after a modal child is closed. .. method:: get_child() -> ~gi.repository.Gtk.Widget | None Gets the child widget of ``popover``. .. method:: get_has_arrow() -> bool Gets whether this popover is showing an arrow pointing at the widget that it is relative to. .. method:: get_mnemonics_visible() -> bool Gets whether mnemonics are visible. .. method:: get_offset() -> tuple[int, int] Gets the offset previous set with :obj:`~gi.repository.Gtk.Popover.set_offset()`. .. method:: get_pointing_to() -> tuple[bool, ~gi.repository.Gdk.Rectangle] Gets the rectangle that the popover points to. If a rectangle to point to has been set, this function will return :const:`True` and fill in ``rect`` with such rectangle, otherwise it will return :const:`False` and fill in ``rect`` with the parent widget coordinates. .. method:: get_position() -> ~gi.repository.Gtk.PositionType Returns the preferred position of ``popover``. .. method:: popdown() -> None Pops ``popover`` down. This may have the side-effect of closing a parent popover as well. See :obj:`~gi.repository.Gtk.Popover.props.cascade_popdown`. .. method:: popup() -> None Pops ``popover`` up. .. method:: present() -> None Allocate a size for the ``GtkPopover``. This function needs to be called in size-allocate by widgets who have a ``GtkPopover`` as child. When using a layout manager, this is happening automatically. To make a popover appear on screen, use :obj:`~gi.repository.Gtk.Popover.popup`. .. method:: set_autohide(autohide: bool) -> None Sets whether ``popover`` is modal. A modal popover will grab the keyboard focus on it when being displayed. Focus will wrap around within the popover. Clicking outside the popover area or pressing Esc will dismiss the popover. Called this function on an already showing popup with a new autohide value different from the current one, will cause the popup to be hidden. :param autohide: :const:`True` to dismiss the popover on outside clicks .. method:: set_cascade_popdown(cascade_popdown: bool) -> None If ``cascade_popdown`` is :const:`True`, the popover will be closed when a child modal popover is closed. If :const:`False`, ``popover`` will stay visible. :param cascade_popdown: :const:`True` if the popover should follow a child closing .. method:: set_child(child: ~gi.repository.Gtk.Widget | None = None) -> None Sets the child widget of ``popover``. :param child: the child widget .. method:: set_default_widget(widget: ~gi.repository.Gtk.Widget | None = None) -> None Sets the default widget of a ``GtkPopover``. The default widget is the widget that’s activated when the user presses Enter in a dialog (for example). This function sets or unsets the default widget for a ``GtkPopover``. :param widget: a child widget of ``popover`` to set as the default, or :const:`None` to unset the default widget for the popover .. method:: set_has_arrow(has_arrow: bool) -> None Sets whether this popover should draw an arrow pointing at the widget it is relative to. :param has_arrow: :const:`True` to draw an arrow .. method:: set_mnemonics_visible(mnemonics_visible: bool) -> None Sets whether mnemonics should be visible. :param mnemonics_visible: the new value .. method:: set_offset(x_offset: int, y_offset: int) -> None Sets the offset to use when calculating the position of the popover. These values are used when preparing the :obj:`~gi.repository.Gdk.PopupLayout` for positioning the popover. :param x_offset: the x offset to adjust the position by :param y_offset: the y offset to adjust the position by .. method:: set_pointing_to(rect: ~gi.repository.Gdk.Rectangle | None = None) -> None Sets the rectangle that ``popover`` points to. This is in the coordinate space of the ``popover`` parent. :param rect: rectangle to point to .. method:: set_position(position: ~gi.repository.Gtk.PositionType) -> None Sets the preferred position for ``popover`` to appear. If the ``popover`` is currently visible, it will be immediately updated. This preference will be respected where possible, although on lack of space (eg. if close to the window edges), the ``GtkPopover`` may choose to appear on the opposite side. :param position: preferred popover position Properties ---------- .. rst-class:: interim-class .. class:: Popover :no-index: .. attribute:: props.autohide :type: bool Whether to dismiss the popover on outside clicks. .. attribute:: props.cascade_popdown :type: bool Whether the popover pops down after a child popover. This is used to implement the expected behavior of submenus. .. attribute:: props.child :type: ~gi.repository.Gtk.Widget The child widget. .. attribute:: props.default_widget :type: ~gi.repository.Gtk.Widget The default widget inside the popover. .. attribute:: props.has_arrow :type: bool Whether to draw an arrow. .. attribute:: props.mnemonics_visible :type: bool Whether mnemonics are currently visible in this popover. .. attribute:: props.pointing_to :type: ~gi.repository.Gdk.Rectangle Rectangle in the parent widget that the popover points to. .. attribute:: props.position :type: ~gi.repository.Gtk.PositionType How to place the popover, relative to its parent. Signals ------- .. rst-class:: interim-class .. class:: Popover.signals :no-index: .. method:: activate_default() -> None Emitted whend the user activates the default widget. This is a `keybinding signal `_. .. method:: closed() -> None Emitted when the popover is closed. Virtual Methods --------------- .. rst-class:: interim-class .. class:: Popover :no-index: .. method:: do_activate_default() -> None .. method:: do_closed() -> None Fields ------ .. rst-class:: interim-class .. class:: Popover :no-index: .. attribute:: parent