:right-sidebar: True Popup =================================================================== .. currentmodule:: gi.repository.Gdk .. class:: Popup(*args, **kwargs) :no-contents-entry: A ``GdkPopup`` is a surface that is attached to another surface. The ``GdkPopup`` is positioned relative to its parent surface. ``GdkPopup``\s are typically used to implement menus and similar popups. They can be modal, which is indicated by the :obj:`~gi.repository.Gdk.Popup.props.autohide` property. Methods ------- .. rst-class:: interim-class .. class:: Popup :no-index: .. method:: get_autohide() -> bool Returns whether this popup is set to hide on outside clicks. .. method:: get_parent() -> ~gi.repository.Gdk.Surface | None Returns the parent surface of a popup. .. method:: get_position_x() -> int Obtains the position of the popup relative to its parent. .. method:: get_position_y() -> int Obtains the position of the popup relative to its parent. .. method:: get_rect_anchor() -> ~gi.repository.Gdk.Gravity Gets the current popup rectangle anchor. The value returned may change after calling :obj:`~gi.repository.Gdk.Popup.present`\, or after the :obj:`~gi.repository.Gdk.Surface.signals.layout` signal is emitted. .. method:: get_surface_anchor() -> ~gi.repository.Gdk.Gravity Gets the current popup surface anchor. The value returned may change after calling :obj:`~gi.repository.Gdk.Popup.present`\, or after the :obj:`~gi.repository.Gdk.Surface.signals.layout` signal is emitted. .. method:: present(width: int, height: int, layout: ~gi.repository.Gdk.PopupLayout) -> bool Present ``popup`` after having processed the ``GdkPopupLayout`` rules. If the popup was previously not showing, it will be shown, otherwise it will change position according to ``layout``\. After calling this function, the result should be handled in response to the :obj:`~gi.repository.Gdk.Surface.signals.layout` signal being emitted. The resulting popup position can be queried using :obj:`~gi.repository.Gdk.Popup.get_position_x`\, :obj:`~gi.repository.Gdk.Popup.get_position_y`\, and the resulting size will be sent as parameters in the layout signal. Use :obj:`~gi.repository.Gdk.Popup.get_rect_anchor` and :obj:`~gi.repository.Gdk.Popup.get_surface_anchor` to get the resulting anchors. Presenting may fail, for example if the ``popup`` is set to autohide and is immediately hidden upon being presented. If presenting failed, the :obj:`~gi.repository.Gdk.Surface.signals.layout` signal will not me emitted. :param width: the unconstrained popup width to layout :param height: the unconstrained popup height to layout :param layout: the ``GdkPopupLayout`` object used to layout Properties ---------- .. rst-class:: interim-class .. class:: Popup :no-index: .. attribute:: props.autohide :type: bool The type of the None singleton. .. attribute:: props.parent :type: ~gi.repository.Gdk.Surface The type of the None singleton.