Gtk.Popover - Classes - Gtk 3.0 (original) (raw)
g Atk.ImplementorIface Atk.ImplementorIface Gtk.Widget Gtk.Widget Atk.ImplementorIface->Gtk.Widget GObject.GInterface GObject.GInterface GObject.GInterface->Atk.ImplementorIface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable GObject.InitiallyUnowned GObject.InitiallyUnowned GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Bin Gtk.Bin Gtk.Popover Gtk.Popover Gtk.Bin->Gtk.Popover Gtk.Buildable->Gtk.Widget Gtk.Container Gtk.Container Gtk.Container->Gtk.Bin Gtk.Widget->Gtk.Container
Subclasses:
Methods¶
Inherited:
Gtk.Bin (1), Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10)
Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
class | new (relative_to) |
---|---|
class | new_from_model (relative_to, model) |
bind_model (model, action_namespace) | |
get_constrain_to () | |
get_default_widget () | |
get_modal () | |
get_pointing_to () | |
get_position () | |
get_relative_to () | |
get_transitions_enabled () | |
popdown () | |
popup () | |
set_constrain_to (constraint) | |
set_default_widget (widget) | |
set_modal (modal) | |
set_pointing_to (rect) | |
set_position (position) | |
set_relative_to (relative_to) | |
set_transitions_enabled (transitions_enabled) |
Virtual Methods¶
Inherited:
Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10)
do_closed () |
---|
Properties¶
Inherited:
Gtk.Container (3), Gtk.Widget (39)
Name | Type | Flags | Short Description |
---|---|---|---|
constrain-to | Gtk.PopoverConstraint | r/w/en | Constraint for the popover position |
modal | bool | r/w/en | Whether the popover is modal |
pointing-to | Gdk.Rectangle | r/w | Rectangle the bubble window points to |
position | Gtk.PositionType | r/w/en | Position to place the bubble window |
relative-to | Gtk.Widget | r/w | Widget the bubble window points to |
transitions-enabled | bool | d/r/w/en | Whether show/hide transitions are enabled or not deprecated |
Style Properties¶
Inherited:
Signals¶
Inherited:
Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)
Name | Short Description |
---|---|
closed | This signal is emitted when the popover is dismissed either through API or user interaction. |
Fields¶
Inherited:
Gtk.Container (4), Gtk.Widget (69), GObject.Object (1)
Name | Type | Access | Description |
---|---|---|---|
parent_instance | Gtk.Bin | r |
Class Details¶
class Gtk.Popover(**kwargs)¶
Bases:
Abstract:
No
Structure:
Gtk.Popover is a bubble-like context window, primarily meant to provide context-dependent information or options. Popovers are attached to a widget, passed at construction time on Gtk.Popover.new(), or updated afterwards through Gtk.Popover.set_relative_to(), by default they will point to the whole widget area, although this behavior can be changed through Gtk.Popover.set_pointing_to().
The position of a popover relative to the widget it is attached to can also be changed through Gtk.Popover.set_position().
By default, Gtk.Popover performs a GTK+ grab, in order to ensure input events get redirected to it while it is shown, and also so the popover is dismissed in the expected situations (clicks outside the popover, or the Esc key being pressed). If no such modal behavior is desired on a popover, Gtk.Popover.set_modal() may be called on it to tweak its behavior.
Gtk.Popover as menu replacement
Gtk.Popover is often used to replace menus. To facilitate this, it supports being populated from a Gio.MenuModel, usingGtk.Popover.new_from_model(). In addition to all the regular menu model features, this function supports rendering sections in the model in a more compact form, as a row of icon buttons instead of menu items.
To use this rendering, set the ”display-hint” attribute of the section to ”horizontal-buttons” and set the icons of your items with the ”verb-icon” attribute.
CSS nodes
Gtk.Popover has a single css node called popover. It always gets the .background style class and it gets the .menu style class if it is menu-like (e.g. Gtk.PopoverMenu or created using Gtk.Popover.new_from_model().
Particular uses of Gtk.Popover, such as touch selection popups or magnifiers in Gtk.Entry or Gtk.TextView get style classes like .touch-selection or .magnifier to differentiate from plain popovers.
New in version 3.12.
classmethod new(relative_to)[source]¶
Parameters:
relative_to (Gtk.Widget or None) – Gtk.Widget the popover is related to
Returns:
a new Gtk.Popover
Return type:
Creates a new popover to point to relative_to
New in version 3.12.
classmethod new_from_model(relative_to, model)[source]¶
Parameters:
- relative_to (Gtk.Widget or None) – Gtk.Widget the popover is related to
- model (Gio.MenuModel) – a Gio.MenuModel
Returns:
the new Gtk.Popover
Return type:
Creates a Gtk.Popover and populates it according tomodel. The popover is pointed to the relative_to widget.
The created buttons are connected to actions found in theGtk.ApplicationWindow to which the popover belongs - typically by means of being attached to a widget that is contained within the Gtk.ApplicationWindows widget hierarchy.
Actions can also be added using Gtk.Widget.insert_action_group() on the menus attach widget or on any of its parent widgets.
New in version 3.12.
bind_model(model, action_namespace)[source]¶
Parameters:
- model (Gio.MenuModel or None) – the Gio.MenuModel to bind to or None to remove binding
- action_namespace (str or None) – the namespace for actions in model
Establishes a binding between a Gtk.Popover and a Gio.MenuModel.
The contents of self are removed and then refilled with menu items according to model. When model changes, self is updated. Calling this function twice on self with different model will cause the first binding to be replaced with a binding to the new model. If model is None then any previous binding is undone and all children are removed.
If action_namespace is non-None then the effect is as if all actions mentioned in the model have their names prefixed with the namespace, plus a dot. For example, if the action “quit” is mentioned and action_namespace is “app” then the effective action name is “app.quit”.
This function uses Gtk.Actionable to define the action name and target values on the created menu items. If you want to use an action group other than “app” and “win”, or if you want to use aGtk.MenuShell outside of a Gtk.ApplicationWindow, then you will need to attach your own action group to the widget hierarchy usingGtk.Widget.insert_action_group(). As an example, if you created a group with a “quit” action and inserted it with the name “mygroup” then you would use the action name “mygroup.quit” in yourGio.MenuModel.
New in version 3.12.
Returns:
the constraint for placing this popover.
Return type:
Returns the constraint for placing this popover. See Gtk.Popover.set_constrain_to().
New in version 3.20.
Returns:
the default widget, or None if there is none
Return type:
Gtk.Widget or None
Gets the widget that should be set as the default while the popover is shown.
New in version 3.18.
Returns:
True if self is modal
Return type:
Returns whether the popover is modal, see Gtk.Popover.set_modal to see the implications of this.
New in version 3.12.
Returns:
True if a rectangle to point to was set.
rect:
location to store the rectangle
Return type:
(bool, rect: Gdk.Rectangle)
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 attached widget width and height if a widget exists, otherwise it will zero-out rect.
Returns:
The preferred position.
Return type:
Returns the preferred position of self.
Returns:
Return type:
Returns the widget self is currently attached to
New in version 3.12.
get_transitions_enabled()[source]¶
Returns:
True if the show and hide transitions of the given popover are enabled, False otherwise.
Return type:
Returns whether show/hide transitions are enabled on this popover.
New in version 3.16.
Deprecated since version 3.22: You can show or hide the popover without transitions using Gtk.Widget.show() and Gtk.Widget.hide() while Gtk.Popover.popup() and Gtk.Popover.popdown() will use transitions.
Pops self down.This is different than a Gtk.Widget.hide() call in that it shows the popover with a transition. If you want to hide the popover without a transition, use Gtk.Widget.hide().
New in version 3.22.
Pops self up. This is different than a Gtk.Widget.show() call in that it shows the popover with a transition. If you want to show the popover without a transition, use Gtk.Widget.show().
New in version 3.22.
set_constrain_to(constraint)[source]¶
Parameters:
constraint (Gtk.PopoverConstraint) – the new constraint
Sets a constraint for positioning this popover.
Note that not all platforms support placing popovers freely, and may already impose constraints.
New in version 3.20.
set_default_widget(widget)[source]¶
Parameters:
widget (Gtk.Widget or None) – the new default widget, or None
Sets the widget that should be set as default widget while the popover is shown (see Gtk.Window.set_default()). Gtk.Popoverremembers the previous default widget and reestablishes it when the popover is dismissed.
New in version 3.18.
Parameters:
modal (bool) – True to make popover claim all input within the toplevel
Sets whether self is modal, a modal popover will grab all input within the toplevel and grab the keyboard focus on it when being displayed. Clicking outside the popover area or pressing Esc will dismiss the popover and ungrab input.
New in version 3.12.
set_pointing_to(rect)[source]¶
Parameters:
rect (Gdk.Rectangle) – rectangle to point to
Sets the rectangle that self will point to, in the coordinate space of the widget self is attached to, see Gtk.Popover.set_relative_to().
New in version 3.12.
set_position(position)[source]¶
Parameters:
position (Gtk.PositionType) – preferred popover position
Sets the preferred position for self to appear. If the selfis 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), theGtk.Popover may choose to appear on the opposite side
New in version 3.12.
set_relative_to(relative_to)[source]¶
Parameters:
relative_to (Gtk.Widget or None) – a Gtk.Widget
Sets a new widget to be attached to self. If self is visible, the position will be updated.
Note: the ownership of popovers is always given to their relative_towidget, so if relative_to is set to None on an attached self, it will be detached from its previous widget, and consequently destroyed unless extra references are kept.
New in version 3.12.
set_transitions_enabled(transitions_enabled)[source]¶
Parameters:
transitions_enabled (bool) – Whether transitions are enabled
Sets whether show/hide transitions are enabled on this popover
New in version 3.16.
Deprecated since version 3.22: You can show or hide the popover without transitions using Gtk.Widget.show() and Gtk.Widget.hide() while Gtk.Popover.popup() and Gtk.Popover.popdown() will use transitions.
do_closed() virtual¶
Signal Details¶
Gtk.Popover.signals.closed(popover)¶
Signal Name:
closed
Flags:
Parameters:
popover (Gtk.Popover) – The object which received the signal
This signal is emitted when the popover is dismissed either through API or user interaction.
New in version 3.12.
Property Details¶
Gtk.Popover.props.constrain_to¶
Name:
constrain-to
Type:
Default Value:
Flags:
READABLE, WRITABLE, EXPLICIT_NOTIFY
Sets a constraint for the popover position.
New in version 3.20.
Gtk.Popover.props.modal¶
Name:
modal
Type:
Default Value:
Flags:
READABLE, WRITABLE, EXPLICIT_NOTIFY
Sets whether the popover is modal (so other elements in the window do not receive input while the popover is visible).
New in version 3.12.
Gtk.Popover.props.pointing_to¶
Name:
pointing-to
Type:
Default Value:
Flags:
Marks a specific rectangle to be pointed.
New in version 3.12.
Gtk.Popover.props.position¶
Name:
position
Type:
Default Value:
Flags:
READABLE, WRITABLE, EXPLICIT_NOTIFY
Sets the preferred position of the popover.
New in version 3.12.
Gtk.Popover.props.relative_to¶
Name:
relative-to
Type:
Default Value:
Flags:
Sets the attached widget.
New in version 3.12.
Gtk.Popover.props.transitions_enabled¶
Name:
transitions-enabled
Type:
Default Value:
Flags:
DEPRECATED, READABLE, WRITABLE, EXPLICIT_NOTIFY
Whether show/hide transitions are enabled for this popover.
New in version 3.16.
Deprecated since version 3.22: You can show or hide the popover without transitions using Gtk.Widget.show() and Gtk.Widget.hide() while Gtk.Popover.popup() and Gtk.Popover.popdown() will use transitions.