Popover

class Popover(**properties: Any)

Superclasses: Widget, InitiallyUnowned, Object

Subclasses: EmojiChooser, PopoverMenu

Implemented Interfaces: Accessible, Buildable, ConstraintTarget, Native, ShortcutManager

Constructors:

Popover(**properties)
new() -> Gtk.Widget

Constructors

class Popover
classmethod new() Widget

Creates a new GtkPopover.

Methods

class Popover
get_autohide() bool

Returns whether the popover is modal.

See set_autohide for the implications of this.

get_cascade_popdown() bool

Returns whether the popover will close after a modal child is closed.

get_child() Widget | None

Gets the child widget of popover.

get_has_arrow() bool

Gets whether this popover is showing an arrow pointing at the widget that it is relative to.

get_mnemonics_visible() bool

Gets whether mnemonics are visible.

get_offset() tuple[int, int]

Gets the offset previous set with set_offset().

get_pointing_to() tuple[bool, Rectangle]

Gets the rectangle that the popover points to.

If a rectangle to point to has been set, this function will return True and fill in rect with such rectangle, otherwise it will return False and fill in rect with the parent widget coordinates.

get_position() PositionType

Returns the preferred position of popover.

popdown() None

Pops popover down.

This may have the side-effect of closing a parent popover as well. See cascade_popdown.

popup() None

Pops popover up.

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 popup.

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.

Parameters:

autohideTrue to dismiss the popover on outside clicks

set_cascade_popdown(cascade_popdown: bool) None

If cascade_popdown is True, the popover will be closed when a child modal popover is closed.

If False, popover will stay visible.

Parameters:

cascade_popdownTrue if the popover should follow a child closing

set_child(child: Widget | None = None) None

Sets the child widget of popover.

Parameters:

child – the child widget

set_default_widget(widget: 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.

Parameters:

widget – a child widget of popover to set as the default, or None to unset the default widget for the popover

set_has_arrow(has_arrow: bool) None

Sets whether this popover should draw an arrow pointing at the widget it is relative to.

Parameters:

has_arrowTrue to draw an arrow

set_mnemonics_visible(mnemonics_visible: bool) None

Sets whether mnemonics should be visible.

Parameters:

mnemonics_visible – the new value

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 PopupLayout for positioning the popover.

Parameters:
  • x_offset – the x offset to adjust the position by

  • y_offset – the y offset to adjust the position by

set_pointing_to(rect: Rectangle | None = None) None

Sets the rectangle that popover points to.

This is in the coordinate space of the popover parent.

Parameters:

rect – rectangle to point to

set_position(position: 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.

Parameters:

position – preferred popover position

Properties

class Popover
props.autohide: bool

Whether to dismiss the popover on outside clicks.

props.cascade_popdown: bool

Whether the popover pops down after a child popover.

This is used to implement the expected behavior of submenus.

props.child: Widget

The child widget.

props.default_widget: Widget

The default widget inside the popover.

props.has_arrow: bool

Whether to draw an arrow.

props.mnemonics_visible: bool

Whether mnemonics are currently visible in this popover.

props.pointing_to: Rectangle

Rectangle in the parent widget that the popover points to.

props.position: PositionType

How to place the popover, relative to its parent.

Signals

class Popover.signals
activate_default() None

Emitted whend the user activates the default widget.

This is a keybinding signal.

closed() None

Emitted when the popover is closed.

Virtual Methods

class Popover
do_activate_default() None
do_closed() None

Fields

class Popover
parent