Gtk.Popover¶
- Subclasses:
Methods¶
- Inherited:
Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Native (6)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9), Gtk.ShortcutManager (2)
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w |
|||
r/w/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted whend the user activates the default widget. |
|
Emitted when the popover is closed. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Gtk.Popover(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
GtkPopover
is a bubble-like context popup.An example
Gtk.Popover
It is primarily meant to provide context-dependent information or options. Popovers are attached to a parent widget. By default, they point to the whole widget area, although this behavior can be changed with [method`Gtk`.Popover.set_pointing_to].
The position of a popover relative to the widget it is attached to can also be changed with [method`Gtk`.Popover.set_position]
By default,
GtkPopover
performs a 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 Escape key being pressed). If no such modal behavior is desired on a popover, [method`Gtk`.Popover.set_autohide] may be called on it to tweak its behavior.Gtk.Popover
as menu replacement
GtkPopover
is often used to replace menus. The best was to do this is to use the [class`Gtk`.PopoverMenu] subclass which supports being populated from aGMenuModel
with [ctor`Gtk`.PopoverMenu.new_from_model].``xml <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
`` popover.background[.menu] ├── arrow ╰── contents
╰── <child>
GtkPopover
has a main node with namepopover
, an arrow with namearrow
, and another node for the content namedcontents
. Thepopover
node always gets the.background
style class. It also gets the.menu
style class if the popover is menu-like, e.g. is a [class`Gtk`.PopoverMenu].Particular uses of
GtkPopover
, such as touch selection popups or magnifiers inGtkEntry
orGtkTextView
get style classes like.touch-selection
or.magnifier
to differentiate from plain popovers.When styling a popover directly, the
popover
node should usually not have any background. The visible part of the popover can have a shadow. To specify it in CSS, set the box-shadow of thecontents
node.Note that, in order to accomplish appropriate arrow visuals,
GtkPopover
uses custom drawing for thearrow
node. This makes it possible for the arrow to change its shape dynamically, but it also limits the possibilities of styling it using CSS. In particular, thearrow
gets drawn over thecontent
node’s border and shadow, so they look like one shape, which means that the border width of thecontent
node and thearrow
node should be the same. The arrow also does not support any border shape other than solid, no border-radius, only one border width (border-bottom-width is used) and no box-shadow.- get_autohide()[source]¶
-
Returns whether the popover is modal.
See [method`Gtk`.Popover.set_autohide] for the implications of this.
- get_cascade_popdown()[source]¶
-
Returns whether the popover will close after a modal child is closed.
- get_child()[source]¶
- Returns:
the child widget of self
- Return type:
Gtk.Widget
orNone
Gets the child widget of self.
- get_has_arrow()[source]¶
- Returns:
whether the popover has an arrow
- Return type:
Gets whether this popover is showing an arrow pointing at the widget that it is relative to.
- get_offset()[source]¶
- Returns:
- x_offset:
a location for the x_offset
- y_offset:
a location for the y_offset
- Return type:
Gets the offset previous set with [method`Gtk`.Popover.set_offset()].
- 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
)
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 returnFalse
and fill in rect with the parent widget coordinates.
- get_position()[source]¶
- Returns:
The preferred position.
- Return type:
Returns the preferred position of self.
- popdown()[source]¶
Pops self down.
This may have the side-effect of closing a parent popover as well. See [property`Gtk`.Popover:cascade-popdown].
- present()[source]¶
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 [method`Gtk`.Popover.popup].
- set_autohide(autohide)[source]¶
-
Sets whether self 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.
- set_cascade_popdown(cascade_popdown)[source]¶
-
If cascade_popdown is
True
, the popover will be closed when a child modal popover is closed.If
False
, self will stay visible.
- set_child(child)[source]¶
- Parameters:
child (
Gtk.Widget
orNone
) – the child widget
Sets the child widget of self.
- set_default_widget(widget)[source]¶
- Parameters:
widget (
Gtk.Widget
orNone
) – a child widget of self to set as the default, orNone
to unset the default widget for the popover
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
.
- set_has_arrow(has_arrow)[source]¶
-
Sets whether this popover should draw an arrow pointing at the widget it is relative to.
- set_mnemonics_visible(mnemonics_visible)[source]¶
- Parameters:
mnemonics_visible (
bool
) – the new value
Sets whether mnemonics should be visible.
- set_offset(x_offset, y_offset)[source]¶
- Parameters:
Sets the offset to use when calculating the position of the popover.
These values are used when preparing the [struct`Gdk`.PopupLayout] for positioning the popover.
- set_pointing_to(rect)[source]¶
- Parameters:
rect (
Gdk.Rectangle
orNone
) – rectangle to point to
Sets the rectangle that self points to.
This is in the coordinate space of the self parent.
- 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
GtkPopover
may choose to appear on the opposite side.
- do_activate_default() virtual¶
- do_closed() virtual¶
Signal Details¶
- Gtk.Popover.signals.activate_default(popover)¶
- Signal Name:
activate-default
- Flags:
- Parameters:
popover (
Gtk.Popover
) – The object which received the signal
Emitted whend the user activates the default widget.
This is a keybinding signal.
- Gtk.Popover.signals.closed(popover)¶
- Signal Name:
closed
- Flags:
- Parameters:
popover (
Gtk.Popover
) – The object which received the signal
Emitted when the popover is closed.
Property Details¶
- Gtk.Popover.props.autohide¶
- Name:
autohide
- Type:
- Default Value:
- Flags:
Whether to dismiss the popover on outside clicks.
- Gtk.Popover.props.cascade_popdown¶
- Name:
cascade-popdown
- Type:
- Default Value:
- Flags:
Whether the popover pops down after a child popover.
This is used to implement the expected behavior of submenus.
- Gtk.Popover.props.child¶
- Name:
child
- Type:
- Default Value:
- Flags:
The child widget.
- Gtk.Popover.props.default_widget¶
- Name:
default-widget
- Type:
- Default Value:
- Flags:
The default widget inside the popover.
- Gtk.Popover.props.has_arrow¶
- Name:
has-arrow
- Type:
- Default Value:
- Flags:
Whether to draw an arrow.
- Gtk.Popover.props.mnemonics_visible¶
- Name:
mnemonics-visible
- Type:
- Default Value:
- Flags:
Whether mnemonics are currently visible in this popover.
- Gtk.Popover.props.pointing_to¶
- Name:
pointing-to
- Type:
- Default Value:
- Flags:
Rectangle in the parent widget that the popover points to.
- Gtk.Popover.props.position¶
- Name:
position
- Type:
- Default Value:
- Flags:
How to place the popover, relative to its parent.