Skip to content

Gtk.PopoverBin

class — extends Widget, Accessible, Buildable, ConstraintTarget

A single child container with a popover.

You should use GtkPopoverBin whenever you need to present a Popover to the user.

Actions

GtkPopoverBin defines the menu.popup action, which can be activated to present the popover to the user.

CSS nodes

GtkPopoverBin has a single CSS node with the name popoverbin.

Constructors

new

@classmethod
def new(cls) -> Widget

Creates a new popover bin widget.

Methods

get_child

def get_child(self) -> Widget | None

Retrieves the child widget of the popover bin.

get_handle_input

def get_handle_input(self) -> bool

get_menu_model

def get_menu_model(self) -> Gio.MenuModel | None

Retrieves the menu model set using PopoverBin.set_menu_model.

get_popover

def get_popover(self) -> Popover | None

Retrieves the GtkPopover set using PopoverBin.set_popover.

popdown

def popdown(self) -> None

Hides the popover from the user.

See: PopoverBin.popup

popup

def popup(self) -> None

Presents the popover to the user.

Use PopoverBin.set_popover or PopoverBin.set_menu_model to define the popover.

See: PopoverBin.popdown

set_child

def set_child(self, child: Widget | None = ...) -> None

Sets the child of the popover bin.

Parameters:

  • child — the child of the popover bin

set_handle_input

def set_handle_input(self, handle_input: bool) -> None

Enables or disables input handling.

If enabled, the popover bin will pop up the popover on right-click or long press, as expected for a context menu.

Parameters:

  • handle_input — whether to handle input

set_menu_model

def set_menu_model(self, model: Gio.MenuModel | None = ...) -> None

Sets the menu model used to create the popover that will be presented when calling PopoverBin.popup.

If model is NULL, the popover will be unset.

A Popover will be created from the menu model with PopoverMenu.new_from_model. Actions will be connected as documented for this function.

If PopoverBin.popover is already set, it will be dissociated from the popover bin, and the property is set to NULL.

See: PopoverBin.set_popover

Parameters:

  • model — a menu model

set_popover

def set_popover(self, popover: Popover | None = ...) -> None

Sets the GtkPopover that will be presented when calling PopoverBin.popup.

If popover is NULL, the popover will be unset.

If PopoverBin.menu-model is set before calling this function, then the menu model property will be unset.

See: PopoverBin.set_menu_model

Parameters:

  • popover — a GtkPopover

Properties

child

child: Widget  # read/write

The child widget of the popover bin.

handle_input

handle_input: bool  # read/write

Whether the popover bin will handle input to trigger the popup.

menu_model

menu_model: Gio.MenuModel  # read/write

The GMenuModel from which the popup will be created.

See PopoverBin.set_menu_model for the interaction with the PopoverBin.popover property.

popover

popover: Popover  # read/write

The GtkPopover that will be popped up when calling PopoverBin.popup.