Gtk.Popover¶
- 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 |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
Constraint for the popover position |
||
r/w/en |
Whether the popover is modal |
||
r/w |
Rectangle the bubble window points to |
||
r/w/en |
Position to place the bubble window |
||
r/w |
Widget the bubble window points to |
||
d/r/w/en |
Whether show/hide transitions are enabled or not |
Style Properties¶
- Inherited:
Signals¶
- Inherited:
Name |
Short Description |
---|---|
This signal is emitted when the popover is dismissed either through API or user interaction. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
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 onGtk.Popover.new
(), or updated afterwards throughGtk.Popover.set_relative_to
(), by default they will point to the whole widget area, although this behavior can be changed throughGtk.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 aGio.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.
<section> <attribute name="display-hint">horizontal-buttons</attribute> <item> <attribute name="label">Cut</attribute> <attribute name="action">app.cut</attribute> <attribute name="verb-icon">edit-cut-symbolic</attribute> </item> <item> <attribute name="label">Copy</attribute> <attribute name="action">app.copy</attribute> <attribute name="verb-icon">edit-copy-symbolic</attribute> </item> <item> <attribute name="label">Paste</attribute> <attribute name="action">app.paste</attribute> <attribute name="verb-icon">edit-paste-symbolic</attribute> </item> </section>
- 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 usingGtk.Popover.new_from_model
().Particular uses of
Gtk.Popover
, such as touch selection popups or magnifiers inGtk.Entry
orGtk.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
orNone
) –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
orNone
) –Gtk.Widget
the popover is related tomodel (
Gio.MenuModel
) – aGio.MenuModel
- Returns:
the new
Gtk.Popover
- Return type:
Creates a
Gtk.Popover
and populates it according to model. The popover is pointed to the relative_to widget.The created buttons are connected to actions found in the
Gtk.ApplicationWindow
to which the popover belongs - typically by means of being attached to a widget that is contained within theGtk.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
orNone
) – theGio.MenuModel
to bind to orNone
to remove bindingaction_namespace (
str
orNone
) – the namespace for actions in model
Establishes a binding between a
Gtk.Popover
and aGio.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 aGtk.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.
- get_constrain_to()[source]¶
- 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.
- get_default_widget()[source]¶
- Returns:
the default widget, or
None
if there is none- Return type:
Gtk.Widget
orNone
Gets the widget that should be set as the default while the popover is shown.
New in version 3.18.
- get_modal()[source]¶
-
Returns whether the popover is modal, see
Gtk.Popover.set_modal
to see the implications of this.New in version 3.12.
- get_pointing_to()[source]¶
- 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 returnFalse
and fill in rect with the attached widget width and height if a widget exists, otherwise it will zero-out rect.
- get_position()[source]¶
- Returns:
The preferred position.
- Return type:
Returns the preferred position of self.
- get_relative_to()[source]¶
- 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
() andGtk.Widget.hide
() whileGtk.Popover.popup
() andGtk.Popover.popdown
() will use transitions.
- popdown()[source]¶
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, useGtk.Widget.hide
().New in version 3.22.
- popup()[source]¶
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, useGtk.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
orNone
) – the new default widget, orNone
Sets the widget that should be set as default widget while the popover is shown (see
Gtk.Window.set_default
()).Gtk.Popover
remembers the previous default widget and reestablishes it when the popover is dismissed.New in version 3.18.
- set_modal(modal)[source]¶
-
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 self 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
Gtk.Popover
may choose to appear on the opposite sideNew in version 3.12.
- set_relative_to(relative_to)[source]¶
- Parameters:
relative_to (
Gtk.Widget
orNone
) – aGtk.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_to widget, 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
() andGtk.Widget.hide
() whileGtk.Popover.popup
() andGtk.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:
Sets a constraint for the popover position.
New in version 3.20.
- Gtk.Popover.props.modal¶
- Name:
modal
- Type:
- Default Value:
- Flags:
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:
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:
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
() andGtk.Widget.hide
() whileGtk.Popover.popup
() andGtk.Popover.popdown
() will use transitions.