Gtk.Widget¶
- Subclasses:
Gtk.Calendar
,Gtk.CellView
,Gtk.Container
,Gtk.DrawingArea
,Gtk.Entry
,Gtk.GLArea
,Gtk.HSV
,Gtk.Invisible
,Gtk.LevelBar
,Gtk.Misc
,Gtk.ProgressBar
,Gtk.Range
,Gtk.Separator
,Gtk.Spinner
,Gtk.Switch
Methods¶
- Inherited:
- Structs:
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
Whether the application will paint directly on the widget |
||
r/w/en |
Whether the widget can be the default widget |
||
r/w/en |
Whether the widget can accept the input focus |
||
r |
Whether the widget is part of a composite widget |
||
d/r/w/en |
Whether the widget is double buffered |
||
r/w/en |
The event mask that decides what kind of GdkEvents this widget gets |
||
r/w |
Whether widget wants to expand in both directions |
||
r/w/en |
Whether the widget should grab focus when it is clicked with the mouse |
||
r/w/en |
How to position in extra horizontal space |
||
r/w/en |
Whether the widget is the default widget |
||
r/w/en |
Whether the widget has the input focus |
||
r/w/en |
Whether this widget has a tooltip |
||
r/w/en |
Override for height request of the widget, or -1 if natural request should be used |
||
r/w/en |
Whether widget wants more horizontal space |
||
r/w/en |
Whether to use the hexpand property |
||
r/w |
Whether the widget is the focus widget within the toplevel |
||
r/w |
Pixels of extra space on all four sides |
||
r/w/en |
Pixels of extra space on the bottom side |
||
r/w/en |
Pixels of extra space on the end |
||
d/r/w/en |
Pixels of extra space on the left side |
||
d/r/w/en |
Pixels of extra space on the right side |
||
r/w/en |
Pixels of extra space on the start |
||
r/w/en |
Pixels of extra space on the top side |
||
r/w |
The name of the widget |
||
r/w/en |
Whether |
||
r/w/en |
The opacity of the widget, from 0 to 1 |
||
r/w |
The parent widget of this widget. Must be a Container widget |
||
r/w/en |
If |
||
r |
The scaling factor of the window |
||
r/w/en |
Whether the widget responds to input |
||
d/r/w |
The style of the widget, which contains information about how it will look (colors etc) |
||
r/w |
The contents of the tooltip for this widget |
||
r/w |
The contents of the tooltip for this widget |
||
r/w/en |
How to position in extra vertical space |
||
r/w/en |
Whether widget wants more vertical space |
||
r/w/en |
Whether to use the vexpand property |
||
r/w/en |
Whether the widget is visible |
||
r/w/en |
Override for width request of the widget, or -1 if natural request should be used |
||
r |
The widget’s window if it is realized |
Style Properties¶
Name |
Type |
Default |
Flags |
Short Description |
---|---|---|---|---|
|
|
r |
Aspect ratio with which to draw insertion cursor |
|
|
d/r |
Color with which to draw insertion cursor |
||
|
|
d/r |
Dash pattern used to draw the focus indicator. The character values are interpreted as pixel widths of alternating on and off segments of the line. |
|
|
|
d/r |
Width, in pixels, of the focus indicator line |
|
|
|
d/r |
Width, in pixels, between focus indicator and the widget ‘box’ |
|
|
d/r |
Whether to draw the focus indicator inside widgets |
||
|
d/r |
Color of unvisited links |
||
|
|
r |
The length of horizontal scroll arrows |
|
|
|
r |
The length of vertical scroll arrows |
|
|
d/r |
Color with which to draw the secondary insertion cursor when editing mixed right-to-left and left-to-right text |
||
|
|
d/r |
The height of separators if “wide-separators” is |
|
|
|
d/r |
The width of separators if wide-separators is |
|
|
|
r |
Height of text selection handles |
|
|
|
r |
Width of text selection handles |
|
|
d/r |
Color of visited links |
||
|
d/r |
Whether separators have configurable width and should be drawn using a box instead of a line |
||
|
r |
Whether windows can be dragged and maximized by clicking on empty areas |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
The |
|
The |
|
Determines whether an accelerator that activates the signal identified by signal_id can currently be activated. |
|
The |
|
The |
|
The |
|
Emitted when a redirected window belonging to widget gets drawn into. |
|
The |
|
Signals that all holders of a reference to the widget should release the reference that they hold. |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
This signal is emitted when a widget is supposed to render itself. |
|
The |
|
The GTK+ main loop will emit three signals for each GDK event delivered to a widget: one generic |
|
After the emission of the |
|
The |
|
The |
|
Emitted when a pointer or keyboard grab on a window belonging to widget gets broken. |
|
The |
|
The |
|
The |
|
The |
|
The |
|
Gets emitted if keyboard navigation fails. |
|
The |
|
The |
|
The |
|
The default handler for this signal activates widget if group_cycling is |
|
The |
|
The |
|
This signal gets emitted whenever a widget should pop up a context menu. |
|
The |
|
To receive this signal the |
|
To receive this signal the |
|
Emitted when |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
|
The |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gtk.Widget(**kwargs)¶
- Bases:
GObject.InitiallyUnowned
,Atk.ImplementorIface
,Gtk.Buildable
- Abstract:
Yes
- Structure:
Gtk.Widget
is the base class all widgets in GTK+ derive from. It manages the widget lifecycle, states and style.- Height-for-width Geometry Management
GTK+ uses a height-for-width (and width-for-height) geometry management system. Height-for-width means that a widget can change how much vertical space it needs, depending on the amount of horizontal space that it is given (and similar for width-for-height). The most common example is a label that reflows to fill up the available width, wraps to fewer lines, and therefore needs less height.
Height-for-width geometry management is implemented in GTK+ by way of five virtual methods:
There are some important things to keep in mind when implementing height-for-width and when using it in container implementations.
The geometry management system will query a widget hierarchy in only one orientation at a time. When widgets are initially queried for their minimum sizes it is generally done in two initial passes in the
Gtk.SizeRequestMode
chosen by the toplevel.For example, when queried in the normal
Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH
mode: First, the default minimum and natural width for each widget in the interface will be computed usingGtk.Widget.get_preferred_width
(). Because the preferred widths for each container depend on the preferred widths of their children, this information propagates up the hierarchy, and finally a minimum and natural width is determined for the entire toplevel. Next, the toplevel will use the minimum width to query for the minimum height contextual to that width usingGtk.Widget.get_preferred_height_for_width
(), which will also be a highly recursive operation. The minimum height for the minimum width is normally used to set the minimum size constraint on the toplevel (unlessGtk.Window.set_geometry_hints
() is explicitly used instead).After the toplevel window has initially requested its size in both dimensions it can go on to allocate itself a reasonable size (or a size previously specified with
Gtk.Window.set_default_size
()). During the recursive allocation process it’s important to note that request cycles will be recursively executed while container widgets allocate their children. Each container widget, once allocated a size, will go on to first share the space in one orientation among its children and then request each child’s height for its target allocated width or its width for allocated height, depending. In this way aGtk.Widget
will typically be requested its size a number of times before actually being allocated a size. The size a widget is finally allocated can of course differ from the size it has requested. For this reason,Gtk.Widget
caches a small number of results to avoid re-querying for the same sizes in one allocation cycle.See ‘GtkContainer’s geometry management section [container-geometry-management]’ to learn more about how height-for-width allocations are performed by container widgets.
If a widget does move content around to intelligently use up the allocated size then it must support the request in both
Gtk.SizeRequestModes
even if the widget in question only trades sizes in a single orientation.For instance, a
Gtk.Label
that does height-for-width word wrapping will not expect to haveGtk.Widget.do_get_preferred_height
() called because that call is specific to a width-for-height request. In this case the label must return the height required for its own minimum possible width. By following this rule any widget that handles height-for-width or width-for-height requests will always be allocated at least enough space to fit its own content.Here are some examples of how a
Gtk.SizeRequestMode.HEIGHT_FOR_WIDTH
widget generally deals with width-for-height requests, forGtk.Widget.do_get_preferred_height
() it will do:static void foo_widget_get_preferred_height (GtkWidget *widget, gint *min_height, gint *nat_height) { if (i_am_in_height_for_width_mode) { gint min_width, nat_width; GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, &min_width, &nat_width); GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width (widget, min_width, min_height, nat_height); } else { ... some widgets do both. For instance, if a GtkLabel is rotated to 90 degrees it will return the minimum and natural height for the rotated label here. } }
And in
Gtk.Widget.do_get_preferred_width_for_height
() it will simply return the minimum and natural width:static void foo_widget_get_preferred_width_for_height (GtkWidget *widget, gint for_height, gint *min_width, gint *nat_width) { if (i_am_in_height_for_width_mode) { GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget, min_width, nat_width); } else { ... again if a widget is sometimes operating in width-for-height mode (like a rotated GtkLabel) it can go ahead and do its real width for height calculation here. } }
Often a widget needs to get its own request during size request or allocation. For example, when computing height it may need to also compute width. Or when deciding how to use an allocation, the widget may need to know its natural size. In these cases, the widget should be careful to call its virtual methods directly, like this:
GTK_WIDGET_GET_CLASS(widget)->get_preferred_width (widget, &min, &natural);
It will not work to use the wrapper functions, such as
Gtk.Widget.get_preferred_width
() inside your own size request implementation. These return a request adjusted byGtk.SizeGroup
and by theGtk.Widget.do_adjust_size_request
() virtual method. If a widget used the wrappers inside its virtual method implementations, then the adjustments (such as widget margins) would be applied twice. GTK+ therefore does not allow this and will warn if you try to do it.Of course if you are getting the size request for another widget, such as a child of a container, you must use the wrapper APIs. Otherwise, you would not properly consider widget margins,
Gtk.SizeGroup
, and so forth.Since 3.10 GTK+ also supports baseline vertical alignment of widgets. This means that widgets are positioned such that the typographical baseline of widgets in the same row are aligned. This happens if a widget supports baselines, has a vertical alignment of
Gtk.Align.BASELINE
, and is inside a container that supports baselines and has a natural “row” that it aligns to the baseline, or a baseline assigned to it by the grandparent.Baseline alignment support for a widget is done by the
Gtk.Widget.do_get_preferred_height_and_baseline_for_width
() virtual function. It allows you to report a baseline in combination with the minimum and natural height. If there is no baseline you can return -1 to indicate this. The default implementation of this virtual function calls into theGtk.Widget.do_get_preferred_height
() andGtk.Widget.do_get_preferred_height_for_width
(), so if baselines are not supported it doesn’t need to be implemented.If a widget ends up baseline aligned it will be allocated all the space in the parent as if it was
Gtk.Align.FILL
, but the selected baseline can be found viaGtk.Widget.get_allocated_baseline
(). If this has a value other than -1 you need to align the widget such that the baseline appears at the position.- Style Properties
Gtk.Widget
introduces “style properties” - these are basically object properties that are stored not on the object, but in the style object associated to the widget. Style properties are set in resource files. This mechanism is used for configuring such things as the location of the scrollbar arrows through the theme, giving theme authors more control over the look of applications without the need to write a theme engine in C.Use
Gtk.WidgetClass.install_style_property
() to install style properties for a widget class,Gtk.WidgetClass.find_style_property
() orGtk.WidgetClass.list_style_properties
() to get information about existing style properties andGtk.Widget.style_get_property
(), gtk_widget_style_get() or gtk_widget_style_get_valist() to obtain the value of a style property.The
Gtk.Widget
implementation of theGtk.Buildable
interface supports a custom<accelerator>
element, which has attributes named ”key”, ”modifiers” and ”signal” and allows to specify accelerators.An example of a UI definition fragment specifying an accelerator:
<object class="GtkButton"> <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="clicked"/> </object>
In addition to accelerators,
Gtk.Widget
also support a custom<accessible>
element, which supports actions and relations. Properties on the accessible implementation of an object can be set by accessing the internal child “accessible” of aGtk.Widget
.An example of a UI definition fragment specifying an accessible:
<object class="GtkLabel" id="label1"/> <property name="label">I am a Label for a Button</property> </object> <object class="GtkButton" id="button1"> <accessibility> <action action_name="click" translatable="yes">Click the button.</action> <relation target="label1" type="labelled-by"/> </accessibility> <child internal-child="accessible"> <object class="AtkObject" id="a11y-button1"> <property name="accessible-name">Clickable Button</property> </object> </child> </object>
Finally,
Gtk.Widget
allows style information such as style classes to be associated with widgets, using the custom<style>
element:<object class="GtkButton" id="button1"> <style> <class name="my-special-button-class"/> <class name="dark-button"/> </style> </object>
- Building composite widgets from template XML
Gtk.Widget
exposes some facilities to automate the procedure of creating composite widgets usingGtk.Builder
interface description language.To create composite widgets with
Gtk.Builder
XML, one must associate the interface description with the widget class at class initialization time usingGtk.WidgetClass.set_template
().The interface description semantics expected in composite template descriptions is slightly different from regular
Gtk.Builder
XML.Unlike regular interface descriptions,
Gtk.WidgetClass.set_template
() will expect a<template>
tag as a direct child of the toplevel<interface>
tag. The<template>
tag must specify the “class” attribute which must be the type name of the widget. Optionally, the “parent” attribute may be specified to specify the direct parent type of the widget type, this is ignored by theGtk.Builder
but required for Glade to introspect what kind of properties and internal children exist for a given type when the actual type does not exist.The XML which is contained inside the
<template>
tag behaves as if it were added to the<object>
tag defining “widget” itself. You may set properties on widget by inserting<property>
tags into the<template>
tag, and also add<child>
tags to add children and extend “widget” in the normal way you would with<object>
tags.Additionally,
<object>
tags can also be added before and after the initial<template>
tag in the normal way, allowing one to define auxiliary objects which might be referenced by other widgets declared as children of the<template>
tag.An example of a
Gtk.Builder
Template Definition:<interface> <template class="FooWidget" parent="GtkBox"> <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property> <property name="spacing">4</property> <child> <object class="GtkButton" id="hello_button"> <property name="label">Hello World</property> <signal name="clicked" handler="hello_button_clicked" object="FooWidget" swapped="yes"/> </object> </child> <child> <object class="GtkButton" id="goodbye_button"> <property name="label">Goodbye World</property> </object> </child> </template> </interface>
Typically, you’ll place the template fragment into a file that is bundled with your project, using
Gio.Resource
. In order to load the template, you need to callGtk.WidgetClass.set_template_from_resource
() from the class initialization of yourGtk.Widget
type:static void foo_widget_class_init (FooWidgetClass *klass) { // ... gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/com/example/ui/foowidget.ui"); }
You will also need to call
Gtk.Widget.init_template
() from the instance initialization function:static void foo_widget_init (FooWidget *self) { // ... gtk_widget_init_template (GTK_WIDGET (self)); }
You can access widgets defined in the template using the
Gtk.Widget.get_template_child
() function, but you will typically declare a pointer in the instance private data structure of your type using the same name as the widget in the template definition, and call gtk_widget_class_bind_template_child_private() with that name, e.g.typedef struct { GtkWidget *hello_button; GtkWidget *goodbye_button; } FooWidgetPrivate; G_DEFINE_TYPE_WITH_PRIVATE (FooWidget, foo_widget, GTK_TYPE_BOX) static void foo_widget_class_init (FooWidgetClass *klass) { // ... gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/com/example/ui/foowidget.ui"); gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), FooWidget, hello_button); gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), FooWidget, goodbye_button); } static void foo_widget_init (FooWidget *widget) { }
You can also use gtk_widget_class_bind_template_callback() to connect a signal callback defined in the template with a function visible in the scope of the class, e.g.
// the signal handler has the instance and user data swapped // because of the swapped="yes" attribute in the template XML static void hello_button_clicked (FooWidget *self, GtkButton *button) { g_print ("Hello, world!\n"); } static void foo_widget_class_init (FooWidgetClass *klass) { // ... gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/com/example/ui/foowidget.ui"); gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), hello_button_clicked); }
- classmethod bind_template_callback_full(callback_name, callback_symbol)¶
- Parameters:
callback_name (
str
) – The name of the callback as expected in the template XMLcallback_symbol (
GObject.Callback
) – The callback symbol
Declares a callback_symbol to handle callback_name from the template XML defined for widget_type. See
Gtk.Builder.add_callback_symbol
().Note that this must be called from a composite widget classes class initializer after calling
Gtk.WidgetClass.set_template
().New in version 3.10.
- classmethod bind_template_child_full(name, internal_child, struct_offset)¶
- Parameters:
name (
str
) – The “id” of the child defined in the template XMLinternal_child (
bool
) – Whether the child should be accessible as an “internal-child” when this class is used inGtk.Builder
XMLstruct_offset (
int
) – The structure offset into the composite widget’s instance public or private structure where the automated child pointer should be set, or 0 to not assign the pointer.
Automatically assign an object declared in the class template XML to be set to a location on a freshly built instance’s private data, or alternatively accessible via
Gtk.Widget.get_template_child
().The struct can point either into the public instance, then you should use G_STRUCT_OFFSET(WidgetType, member) for struct_offset, or in the private struct, then you should use G_PRIVATE_OFFSET(WidgetType, member).
An explicit strong reference will be held automatically for the duration of your instance’s life cycle, it will be released automatically when
GObject.Object.do_dispose
() runs on your instance and if a struct_offset that is != 0 is specified, then the automatic location in your instance public or private data will be set toNone
. You can however access an automated child pointer the first time your classesGObject.Object.do_dispose
() runs, or alternatively inGtk.Widget.do_destroy
().If internal_child is specified,
Gtk.Buildable.do_get_internal_child
() will be automatically implemented by theGtk.Widget
class so there is no need to implement it manually.The wrapper macros gtk_widget_class_bind_template_child(), gtk_widget_class_bind_template_child_internal(), gtk_widget_class_bind_template_child_private() and gtk_widget_class_bind_template_child_internal_private() might be more convenient to use.
Note that this must be called from a composite widget classes class initializer after calling
Gtk.WidgetClass.set_template
().New in version 3.10.
- classmethod find_style_property(property_name)¶
- Parameters:
property_name (
str
) – the name of the style property to find- Returns:
the
GObject.ParamSpec
of the style property orNone
if class has no style property with that name.- Return type:
Finds a style property of a widget class by name.
New in version 2.2.
- classmethod get_css_name()¶
- Returns:
the CSS name of the given class
- Return type:
Gets the name used by this class for matching in CSS code. See
Gtk.WidgetClass.set_css_name
() for details.New in version 3.20.
- classmethod get_default_direction()[source]¶
- Returns:
the current default direction.
- Return type:
Obtains the current default reading direction. See
Gtk.Widget.set_default_direction
().
- classmethod get_default_style()[source]¶
- Returns:
the default style. This
Gtk.Style
object is owned by GTK+ and should not be modified or freed.- Return type:
Returns the default style used by all widgets initially.
Deprecated since version 3.0: Use
Gtk.StyleContext
instead, andGtk.CssProvider.get_default
() to obtain aGtk.StyleProvider
with the default widget style information.
- classmethod install_style_property(pspec)¶
- Parameters:
pspec (
GObject.ParamSpec
) – theGObject.ParamSpec
for the property
Installs a style property on a widget class. The parser for the style property is determined by the value type of pspec.
- classmethod list_style_properties()¶
- Returns:
a newly allocated array of
GObject.ParamSpec
. The array must be freed withGLib.free
().- Return type:
Returns all style properties of a widget class.
New in version 2.2.
- classmethod pop_composite_child()[source]¶
Cancels the effect of a previous call to
Gtk.Widget.push_composite_child
().Deprecated since version 3.10: Use
Gtk.WidgetClass.set_template
(), or don’t use this API at all.
- classmethod push_composite_child()[source]¶
Makes all newly-created widgets as composite children until the corresponding
Gtk.Widget.pop_composite_child
() call.A composite child is a child that’s an implementation detail of the container it’s inside and should not be visible to people using the container. Composite children aren’t treated differently by GTK+ (but see
Gtk.Container.foreach
() vs.Gtk.Container.forall
()), but e.g. GUI builders might want to treat them in a different way.Deprecated since version 3.10: This API never really worked well and was mostly unused, now we have a more complete mechanism for composite children, see
Gtk.WidgetClass.set_template
().
- classmethod set_accessible_role(role)¶
- Parameters:
role (
Atk.Role
) – The role to use for accessibles created for self
Sets the default
Atk.Role
to be set on accessibles created for widgets of self. Accessibles may decide to not honor this setting if their role reporting is more refined. Calls toGtk.WidgetClass.set_accessible_type
() will reset this value.In cases where you want more fine-grained control over the role of accessibles created for self, you should provide your own accessible type and use
Gtk.WidgetClass.set_accessible_type
() instead.If role is
Atk.Role.INVALID
, the default role will not be changed and the accessible’s default role will be used instead.This function should only be called from class init functions of widgets.
New in version 3.2.
- classmethod set_accessible_type(type)¶
- Parameters:
type (
GObject.GType
) – The object type that implements the accessible for self
Sets the type to be used for creating accessibles for widgets of self. The given type must be a subtype of the type used for accessibles of the parent class.
This function should only be called from class init functions of widgets.
New in version 3.2.
- classmethod set_connect_func(connect_func, *connect_data)¶
- Parameters:
connect_func (
Gtk.BuilderConnectFunc
) – TheGtk.BuilderConnectFunc
to use when connecting signals in the class templateconnect_data (
object
orNone
) – The data to pass to connect_func
For use in language bindings, this will override the default
Gtk.BuilderConnectFunc
to be used when parsingGtk.Builder
XML from this class’s template data.Note that this must be called from a composite widget classes class initializer after calling
Gtk.WidgetClass.set_template
().New in version 3.10.
- classmethod set_css_name(name)¶
- Parameters:
name (
str
) – name to use
Sets the name to be used for CSS matching of widgets.
If this function is not called for a given class, the name of the parent class is used.
New in version 3.20.
- classmethod set_default_direction(dir)[source]¶
- Parameters:
dir (
Gtk.TextDirection
) – the new default direction. This cannot beGtk.TextDirection.NONE
.
Sets the default reading direction for widgets where the direction has not been explicitly set by
Gtk.Widget.set_direction
().
- classmethod set_template(template_bytes)¶
- Parameters:
template_bytes (
GLib.Bytes
) – AGLib.Bytes
holding theGtk.Builder
XML
This should be called at class initialization time to specify the
Gtk.Builder
XML to be used to extend a widget.For convenience,
Gtk.WidgetClass.set_template_from_resource
() is also provided.Note that any class that installs templates must call
Gtk.Widget.init_template
() in the widget’s instance initializer.New in version 3.10.
- classmethod set_template_from_resource(resource_name)¶
- Parameters:
resource_name (
str
) – The name of the resource to load the template from
A convenience function to call
Gtk.WidgetClass.set_template
().Note that any class that installs templates must call
Gtk.Widget.init_template
() in the widget’s instance initializer.New in version 3.10.
- activate()[source]¶
-
For widgets that can be “activated” (buttons, menu items, etc.) this function activates them. Activation is what happens when you press Enter on a widget during key navigation. If self isn’t activatable, the function returns
False
.
- add_accelerator(accel_signal, accel_group, accel_key, accel_mods, accel_flags)[source]¶
- Parameters:
accel_signal (
str
) – widget signal to emit on accelerator activationaccel_group (
Gtk.AccelGroup
) – accel group for this widget, added to its toplevelaccel_key (
int
) – GDK keyval of the acceleratoraccel_mods (
Gdk.ModifierType
) – modifier key combination of the acceleratoraccel_flags (
Gtk.AccelFlags
) – flag accelerators, e.g.Gtk.AccelFlags.VISIBLE
Installs an accelerator for this self in accel_group that causes accel_signal to be emitted if the accelerator is activated. The accel_group needs to be added to the widget’s toplevel via
Gtk.Window.add_accel_group
(), and the signal must be of typeGObject.SignalFlags.ACTION
. Accelerators added through this function are not user changeable during runtime. If you want to support accelerators that can be changed by the user, useGtk.AccelMap.add_entry
() andGtk.Widget.set_accel_path
() orGtk.MenuItem.set_accel_path
() instead.
- add_device_events(device, events)[source]¶
- Parameters:
device (
Gdk.Device
) – aGdk.Device
events (
Gdk.EventMask
) – an event mask, seeGdk.EventMask
Adds the device events in the bitfield events to the event mask for self. See
Gtk.Widget.set_device_events
() for details.New in version 3.0.
- add_events(events)[source]¶
- Parameters:
events (
int
) – an event mask, seeGdk.EventMask
Adds the events in the bitfield events to the event mask for self. See
Gtk.Widget.set_events
() and the input handling overview for details.
- add_mnemonic_label(label)[source]¶
- Parameters:
label (
Gtk.Widget
) – aGtk.Widget
that acts as a mnemonic label for self
Adds a widget to the list of mnemonic labels for this widget. (See
Gtk.Widget.list_mnemonic_labels
()). Note the list of mnemonic labels for the widget is cleared when the widget is destroyed, so the caller must make sure to update its internal state at this point as well, by using a connection to theGtk.Widget
::destroy
signal or a weak notifier.New in version 2.4.
- add_tick_callback(callback, *user_data)[source]¶
- Parameters:
callback (
Gtk.TickCallback
) – function to call for updating animations
- Returns:
an id for the connection of this callback. Remove the callback by passing it to
Gtk.Widget.remove_tick_callback
()- Return type:
Queues an animation frame update and adds a callback to be called before each frame. Until the tick callback is removed, it will be called frequently (usually at the frame rate of the output device or as quickly as the application can be repainted, whichever is slower). For this reason, is most suitable for handling graphics that change every frame or every few frames. The tick callback does not automatically imply a relayout or repaint. If you want a repaint or relayout, and aren’t changing widget properties that would trigger that (for example, changing the text of a
Gtk.Label
), then you will have to callGtk.Widget.queue_resize
() orGtk.Widget.queue_draw_area
() yourself.Gdk.FrameClock.get_frame_time
() should generally be used for timing continuous animations andGdk.FrameTimings.get_predicted_presentation_time
() if you are trying to display isolated frames at particular times.This is a more convenient alternative to connecting directly to the
Gdk.FrameClock
::update
signal ofGdk.FrameClock
, since you don’t have to worry about when aGdk.FrameClock
is assigned to a widget.New in version 3.8.
- can_activate_accel(signal_id)[source]¶
- Parameters:
signal_id (
int
) – the ID of a signal installed on self- Returns:
True
if the accelerator can be activated.- Return type:
Determines whether an accelerator that activates the signal identified by signal_id can currently be activated. This is done by emitting the
Gtk.Widget
::can-activate-accel
signal on self; if the signal isn’t overridden by a handler or in a derived widget, then the default check is that the widget must be sensitive, and the widget and all its ancestors mapped.New in version 2.4.
- child_focus(direction)[source]¶
- Parameters:
direction (
Gtk.DirectionType
) – direction of focus movement- Returns:
True
if focus ended up inside self- Return type:
This function is used by custom widget implementations; if you’re writing an app, you’d use
Gtk.Widget.grab_focus
() to move the focus to a particular widget, andGtk.Container.set_focus_chain
() to change the focus tab order. So you may want to investigate those functions instead.Gtk.Widget.child_focus
() is called by containers as the user moves around the window using keyboard shortcuts. direction indicates what kind of motion is taking place (up, down, left, right, tab forward, tab backward).Gtk.Widget.child_focus
() emits theGtk.Widget
::focus
signal; widgets override the default handler for this signal in order to implement appropriate focus behavior.The default
::focus
handler for a widget should returnTrue
if moving in direction left the focus on a focusable location inside that widget, andFalse
if moving in direction moved the focus outside the widget. If returningTrue
, widgets normally callGtk.Widget.grab_focus
() to place the focus accordingly; if returningFalse
, they don’t modify the current focus location.
- child_notify(child_property)[source]¶
- Parameters:
child_property (
str
) – the name of a child property installed on the class of self’s parent
Emits a
Gtk.Widget
::child-notify
signal for the ‘child property [child-properties]’ child_property on self.This is the analogue of
GObject.Object.notify
() for child properties.Also see
Gtk.Container.child_notify
().
- class_path()[source]¶
- Returns:
- Return type:
Same as
Gtk.Widget.path
(), but always uses the name of a widget’s type, never uses a custom name set withGtk.Widget.set_name
().Deprecated since version 3.0: Use
Gtk.Widget.get_path
() instead
- compute_expand(orientation)[source]¶
- Parameters:
orientation (
Gtk.Orientation
) – expand direction- Returns:
whether widget tree rooted here should be expanded
- Return type:
Computes whether a container should give this widget extra space when possible. Containers should check this, rather than looking at
Gtk.Widget.get_hexpand
() orGtk.Widget.get_vexpand
().This function already checks whether the widget is visible, so visibility does not need to be checked separately. Non-visible widgets are not expanded.
The computed expand value uses either the expand setting explicitly set on the widget itself, or, if none has been explicitly set, the widget may expand if some of its children do.
- create_pango_context()[source]¶
- Returns:
the new
Pango.Context
- Return type:
Creates a new
Pango.Context
with the appropriate font map, font options, font description, and base direction for drawing text for this widget. See alsoGtk.Widget.get_pango_context
().
- create_pango_layout(text)[source]¶
- Parameters:
text (
str
orNone
) – text to set on the layout (can beNone
)- Returns:
the new
Pango.Layout
- Return type:
Creates a new
Pango.Layout
with the appropriate font map, font description, and base direction for drawing text for this widget.If you keep a
Pango.Layout
created in this way around, you need to re-create it when the widgetPango.Context
is replaced. This can be tracked by using theGtk.Widget
::screen-changed
signal on the widget.
- destroy()[source]¶
Destroys a widget.
When a widget is destroyed all references it holds on other objects will be released:
if the widget is inside a container, it will be removed from its parent
if the widget is a container, all its children will be destroyed, recursively
if the widget is a top level, it will be removed from the list of top level widgets that GTK+ maintains internally
It’s expected that all references held on the widget will also be released; you should connect to the
Gtk.Widget
::destroy
signal if you hold a reference to self and you wish to remove it when this function is called. It is not necessary to do so if you are implementing aGtk.Container
, as you’ll be able to use theGtk.Container.do_remove
() virtual function for that.It’s important to notice that
Gtk.Widget.destroy
() will only cause the self to be finalized if no additional references, acquired usingGObject.Object.ref
(), are held on it. In case additional references are in place, the self will be in an “inert” state after calling this function; self will still point to valid memory, allowing you to release the references you hold, but you may not query the widget’s own state.You should typically call this function on top level widgets, and rarely on child widgets.
See also:
Gtk.Container.remove
()
- destroyed(widget_pointer)[source]¶
- Parameters:
widget_pointer (
Gtk.Widget
) – address of a variable that contains self- Returns:
address of a variable that contains self
- Return type:
widget_pointer:
Gtk.Widget
This function sets widget_pointer to
None
if widget_pointer !=None
. It’s intended to be used as a callback connected to the “destroy” signal of a widget. You connectGtk.Widget.destroyed
() as a signal handler, and pass the address of your widget variable as user data. Then when the widget is destroyed, the variable will be set toNone
. Useful for example to avoid multiple copies of the same dialog.
- device_is_shadowed(device)[source]¶
- Parameters:
device (
Gdk.Device
) – aGdk.Device
- Returns:
True
if there is an ongoing grab on device by anotherGtk.Widget
than self.- Return type:
Returns
True
if device has been shadowed by a GTK+ device grab on another widget, so it would stop sending events to self. This may be used in theGtk.Widget
::grab-notify
signal to check for specific devices. SeeGtk.device_grab_add
().New in version 3.0.
- drag_begin(targets, actions, button, event)[source]¶
- Parameters:
targets (
Gtk.TargetList
) – The targets (data formats) in which the source can provide the dataactions (
Gdk.DragAction
) – A bitmask of the allowed drag actions for this dragbutton (
int
) – The button the user clicked to start the dragevent (
Gdk.Event
orNone
) – The event that triggered the start of the drag, orNone
if none can be obtained.
- Returns:
the context for this drag
- Return type:
This function is equivalent to
Gtk.Widget.drag_begin_with_coordinates
(), passing -1, -1 as coordinates.Deprecated since version 3.10: Use
Gtk.Widget.drag_begin_with_coordinates
() instead
- drag_begin_with_coordinates(targets, actions, button, event, x, y)[source]¶
- Parameters:
targets (
Gtk.TargetList
) – The targets (data formats) in which the source can provide the dataactions (
Gdk.DragAction
) – A bitmask of the allowed drag actions for this dragbutton (
int
) – The button the user clicked to start the dragevent (
Gdk.Event
orNone
) – The event that triggered the start of the drag, orNone
if none can be obtained.x (
int
) – The initial x coordinate to start dragging from, in the coordinate space of self. If -1 is passed, the coordinates are retrieved from event or the current pointer positiony (
int
) – The initial y coordinate to start dragging from, in the coordinate space of self. If -1 is passed, the coordinates are retrieved from event or the current pointer position
- Returns:
the context for this drag
- Return type:
Initiates a drag on the source side. The function only needs to be used when the application is starting drags itself, and is not needed when
Gtk.Widget.drag_source_set
() is used.The event is used to retrieve the timestamp that will be used internally to grab the pointer. If event is
None
, thenGdk.CURRENT_TIME
will be used. However, you should try to pass a real event in all cases, since that can be used to get information about the drag.Generally there are three cases when you want to start a drag by hand by calling this function:
During a
Gtk.Widget
::button-press-event
handler, if you want to start a drag immediately when the user presses the mouse button. Pass the event that you have in yourGtk.Widget
::button-press-event
handler.During a
Gtk.Widget
::motion-notify-event
handler, if you want to start a drag when the mouse moves past a certain threshold distance after a button-press. Pass the event that you have in yourGtk.Widget
::motion-notify-event
handler.During a timeout handler, if you want to start a drag after the mouse button is held down for some time. Try to save the last event that you got from the mouse, using
Gdk.Event.copy
(), and pass it to this function (remember to free the event withGdk.Event.free
() when you are done). If you really cannot pass a real event, passNone
instead.New in version 3.10.
- drag_check_threshold(start_x, start_y, current_x, current_y)[source]¶
- Parameters:
- Returns:
True
if the drag threshold has been passed.- Return type:
Checks to see if a mouse drag starting at (start_x, start_y) and ending at (current_x, current_y) has passed the GTK+ drag threshold, and thus should trigger the beginning of a drag-and-drop operation.
- drag_dest_add_image_targets()[source]¶
Add the image targets supported by
Gtk.SelectionData
to the target list of the drag destination. The targets are added with info = 0. If you need another value, useGtk.TargetList.add_image_targets
() andGtk.Widget.drag_dest_set_target_list
().New in version 2.6.
- drag_dest_add_text_targets()[source]¶
Add the text targets supported by
Gtk.SelectionData
to the target list of the drag destination. The targets are added with info = 0. If you need another value, useGtk.TargetList.add_text_targets
() andGtk.Widget.drag_dest_set_target_list
().New in version 2.6.
- drag_dest_add_uri_targets()[source]¶
Add the URI targets supported by
Gtk.SelectionData
to the target list of the drag destination. The targets are added with info = 0. If you need another value, useGtk.TargetList.add_uri_targets
() andGtk.Widget.drag_dest_set_target_list
().New in version 2.6.
- drag_dest_find_target(context, target_list)[source]¶
- Parameters:
context (
Gdk.DragContext
) – drag contexttarget_list (
Gtk.TargetList
orNone
) – list of droppable targets, orNone
to useGtk.Widget.drag_dest_get_target_list
(self).
- Returns:
first target that the source offers and the dest can accept, or %GDK_NONE
- Return type:
Looks for a match between the supported targets of context and the dest_target_list, returning the first matching target, otherwise returning %GDK_NONE. dest_target_list should usually be the return value from
Gtk.Widget.drag_dest_get_target_list
(), but some widgets may have different valid targets for different parts of the widget; in that case, they will have to implement a drag_motion handler that passes the correct target list to this function.
- drag_dest_get_target_list()[source]¶
- Returns:
the
Gtk.TargetList
, orNone
if none- Return type:
Returns the list of targets this widget can accept from drag-and-drop.
- drag_dest_get_track_motion()[source]¶
- Returns:
True
if the widget always emitsGtk.Widget
::drag-motion
events- Return type:
Returns whether the widget has been configured to always emit
Gtk.Widget
::drag-motion
signals.New in version 2.10.
- drag_dest_set(flags, targets, actions)[source]¶
- Parameters:
flags (
Gtk.DestDefaults
) – which types of default drag behavior to usetargets ([
Gtk.TargetEntry
] orNone
) – a pointer to an array ofGtk.TargetEntrys
indicating the drop types that this self will accept, orNone
. Later you can access the list withGtk.Widget.drag_dest_get_target_list
() andGtk.Widget.drag_dest_find_target
().actions (
Gdk.DragAction
) – a bitmask of possible actions for a drop onto this self.
Sets a widget as a potential drop destination, and adds default behaviors.
The default behaviors listed in flags have an effect similar to installing default handlers for the widget’s drag-and-drop signals (
Gtk.Widget
::drag-motion
,Gtk.Widget
::drag-drop
, …). They all exist for convenience. When passingGtk.DestDefaults.ALL
for instance it is sufficient to connect to the widget’sGtk.Widget
::drag-data-received
signal to get primitive, but consistent drag-and-drop support.Things become more complicated when you try to preview the dragged data, as described in the documentation for
Gtk.Widget
::drag-motion
. The default behaviors described by flags make some assumptions, that can conflict with your own signal handlers. For instanceGtk.DestDefaults.DROP
causes invokations ofGdk.drag_status
() in the context ofGtk.Widget
::drag-motion
, and invokations ofGtk.drag_finish
() inGtk.Widget
::drag-data-received
. Especially the later is dramatic, when your ownGtk.Widget
::drag-motion
handler callsGtk.Widget.drag_get_data
() to inspect the dragged data.There’s no way to set a default action here, you can use the
Gtk.Widget
::drag-motion
callback for that. Here’s an example which selects the action to use depending on whether the control key is pressed or not:static void drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time) { GdkModifierType mask; gdk_window_get_pointer (gtk_widget_get_window (widget), NULL, NULL, &mask); if (mask & GDK_CONTROL_MASK) gdk_drag_status (context, GDK_ACTION_COPY, time); else gdk_drag_status (context, GDK_ACTION_MOVE, time); }
- drag_dest_set_proxy(proxy_window, protocol, use_coordinates)[source]¶
- Parameters:
proxy_window (
Gdk.Window
) – the window to which to forward drag eventsprotocol (
Gdk.DragProtocol
) – the drag protocol which the proxy_window accepts (You can use gdk_drag_get_protocol() to determine this)use_coordinates (
bool
) – IfTrue
, send the same coordinates to the destination, because it is an embedded subwindow.
Sets this widget as a proxy for drops to another window.
Deprecated since version 3.22.
- drag_dest_set_target_list(target_list)[source]¶
- Parameters:
target_list (
Gtk.TargetList
orNone
) – list of droppable targets, orNone
for none
Sets the target types that this widget can accept from drag-and-drop. The widget must first be made into a drag destination with
Gtk.Widget.drag_dest_set
().
- drag_dest_set_track_motion(track_motion)[source]¶
- Parameters:
track_motion (
bool
) – whether to accept all targets
Tells the widget to emit
Gtk.Widget
::drag-motion
andGtk.Widget
::drag-leave
events regardless of the targets and theGtk.DestDefaults.MOTION
flag.This may be used when a widget wants to do generic actions regardless of the targets that the source offers.
New in version 2.10.
- drag_dest_unset()[source]¶
Clears information about a drop destination set with
Gtk.Widget.drag_dest_set
(). The widget will no longer receive notification of drags.
- drag_get_data(context, target, time_)[source]¶
- Parameters:
context (
Gdk.DragContext
) – the drag contexttarget (
Gdk.Atom
) – the target (form of the data) to retrievetime (
int
) – a timestamp for retrieving the data. This will generally be the time received in aGtk.Widget
::drag-motion
orGtk.Widget
::drag-drop
signal
Gets the data associated with a drag. When the data is received or the retrieval fails, GTK+ will emit a
Gtk.Widget
::drag-data-received
signal. Failure of the retrieval is indicated by the length field of the selection_data signal parameter being negative. However, whenGtk.Widget.drag_get_data
() is called implicitely because theGtk.DestDefaults.DROP
was set, then the widget will not receive notification of failed drops.
- drag_highlight()[source]¶
Highlights a widget as a currently hovered drop target. To end the highlight, call
Gtk.Widget.drag_unhighlight
(). GTK+ calls this automatically ifGtk.DestDefaults.HIGHLIGHT
is set.
- drag_source_add_image_targets()[source]¶
Add the writable image targets supported by
Gtk.SelectionData
to the target list of the drag source. The targets are added with info = 0. If you need another value, useGtk.TargetList.add_image_targets
() andGtk.Widget.drag_source_set_target_list
().New in version 2.6.
- drag_source_add_text_targets()[source]¶
Add the text targets supported by
Gtk.SelectionData
to the target list of the drag source. The targets are added with info = 0. If you need another value, useGtk.TargetList.add_text_targets
() andGtk.Widget.drag_source_set_target_list
().New in version 2.6.
- drag_source_add_uri_targets()[source]¶
Add the URI targets supported by
Gtk.SelectionData
to the target list of the drag source. The targets are added with info = 0. If you need another value, useGtk.TargetList.add_uri_targets
() andGtk.Widget.drag_source_set_target_list
().New in version 2.6.
- drag_source_get_target_list()[source]¶
- Returns:
the
Gtk.TargetList
, orNone
if none- Return type:
Gets the list of targets this widget can provide for drag-and-drop.
New in version 2.4.
- drag_source_set(start_button_mask, targets, actions)[source]¶
- Parameters:
start_button_mask (
Gdk.ModifierType
) – the bitmask of buttons that can start the dragtargets ([
Gtk.TargetEntry
] orNone
) – the table of targets that the drag will support, may beNone
actions (
Gdk.DragAction
) – the bitmask of possible actions for a drag from this widget
Sets up a widget so that GTK+ will start a drag operation when the user clicks and drags on the widget. The widget must have a window.
- drag_source_set_icon_gicon(icon)[source]¶
-
Sets the icon that will be used for drags from a particular source to icon. See the docs for
Gtk.IconTheme
for more details.New in version 3.2.
- drag_source_set_icon_name(icon_name)[source]¶
- Parameters:
icon_name (
str
) – name of icon to use
Sets the icon that will be used for drags from a particular source to a themed icon. See the docs for
Gtk.IconTheme
for more details.New in version 2.8.
- drag_source_set_icon_pixbuf(pixbuf)[source]¶
- Parameters:
pixbuf (
GdkPixbuf.Pixbuf
) – theGdkPixbuf.Pixbuf
for the drag icon
Sets the icon that will be used for drags from a particular widget from a
GdkPixbuf.Pixbuf
. GTK+ retains a reference for pixbuf and will release it when it is no longer needed.
- drag_source_set_icon_stock(stock_id)[source]¶
- Parameters:
stock_id (
str
) – the ID of the stock icon to use
Sets the icon that will be used for drags from a particular source to a stock icon.
Deprecated since version 3.10: Use
Gtk.Widget.drag_source_set_icon_name
() instead.
- drag_source_set_target_list(target_list)[source]¶
- Parameters:
target_list (
Gtk.TargetList
orNone
) – list of draggable targets, orNone
for none
Changes the target types that this widget offers for drag-and-drop. The widget must first be made into a drag source with
Gtk.Widget.drag_source_set
().New in version 2.4.
- drag_source_unset()[source]¶
Undoes the effects of
Gtk.Widget.drag_source_set
().
- drag_unhighlight()[source]¶
Removes a highlight set by
Gtk.Widget.drag_highlight
() from a widget.
- draw(cr)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo context to draw to
Draws self to cr. The top left corner of the widget will be drawn to the currently set origin point of cr.
You should pass a cairo context as cr argument that is in an original state. Otherwise the resulting drawing is undefined. For example changing the operator using
cairo.Context.set_operator
() or the line width usingcairo.Context.set_line_width
() might have unwanted side effects. You may however change the context’s transform matrix - like withcairo.Context.scale
(),cairo.Context.translate
() orcairo.Context.set_matrix
() and clip region withcairo.Context.clip
() prior to calling this function. Also, it is fine to modify the context withcairo.Context.save
() andcairo.Context.push_group
() prior to calling this function.Note that special-purpose widgets may contain special code for rendering to the screen and might appear differently on screen and when rendered using
Gtk.Widget.draw
().New in version 3.0.
- ensure_style()[source]¶
Ensures that self has a style (self->style).
Not a very useful function; most of the time, if you want the style, the widget is realized, and realized widgets are guaranteed to have a style already.
Deprecated since version 3.0: Use
Gtk.StyleContext
instead
- error_bell()[source]¶
Notifies the user about an input-related error on this widget. If the
Gtk.Settings
:gtk-error-bell
setting isTrue
, it callsGdk.Window.beep
(), otherwise it does nothing.Note that the effect of
Gdk.Window.beep
() can be configured in many ways, depending on the windowing backend and the desktop environment or window manager that is used.New in version 2.12.
- event(event)[source]¶
- Parameters:
- Returns:
return from the event signal emission (
True
if the event was handled)- Return type:
Rarely-used function. This function is used to emit the event signals on a widget (those signals should never be emitted without using this function to do so). If you want to synthesize an event though, don’t use this function; instead, use
Gtk.main_do_event
() so the event will behave as if it were in the event queue. Don’t synthesize expose events; instead, useGdk.Window.invalidate_rect
() to invalidate a region of the window.
- freeze_child_notify()[source]¶
Stops emission of
Gtk.Widget
::child-notify
signals on self. The signals are queued untilGtk.Widget.thaw_child_notify
() is called on self.This is the analogue of
GObject.Object.freeze_notify
() for child properties.
- get_accessible()[source]¶
- Returns:
the
Atk.Object
associated with self- Return type:
Returns the accessible object that describes the widget to an assistive technology.
If accessibility support is not available, this
Atk.Object
instance may be a no-op. Likewise, if no class-specificAtk.Object
implementation is available for the widget instance in question, it will inherit anAtk.Object
implementation from the first ancestor class for which such an implementation is defined.The documentation of the ATK library contains more information about accessible objects and their uses.
- get_action_group(prefix)[source]¶
- Parameters:
prefix (
str
) – The “prefix” of the action group.- Returns:
A
Gio.ActionGroup
orNone
.- Return type:
Retrieves the
Gio.ActionGroup
that was registered using prefix. The resultingGio.ActionGroup
may have been registered to self or anyGtk.Widget
in its ancestry.If no action group was found matching prefix, then
None
is returned.New in version 3.16.
- get_allocated_baseline()[source]¶
- Returns:
the baseline of the self, or -1 if none
- Return type:
Returns the baseline that has currently been allocated to self. This function is intended to be used when implementing handlers for the
Gtk.Widget
::draw
function, and when allocating child widgets in #GtkWidget::size_allocate.New in version 3.10.
- get_allocated_height()[source]¶
- Returns:
the height of the self
- Return type:
Returns the height that has currently been allocated to self. This function is intended to be used when implementing handlers for the
Gtk.Widget
::draw
function.
- get_allocated_size()[source]¶
- Returns:
- allocation:
a pointer to a #GtkAllocation to copy to
- baseline:
a pointer to an integer to copy to
- Return type:
(allocation:
Gdk.Rectangle
, baseline:int
)
Retrieves the widget’s allocated size.
This function returns the last values passed to
Gtk.Widget.size_allocate_with_baseline
(). The value differs from the size returned inGtk.Widget.get_allocation
() in that functions likeGtk.Widget.set_halign
() can adjust the allocation, but not the value returned by this function.If a widget is not visible, its allocated size is 0.
New in version 3.20.
- get_allocated_width()[source]¶
- Returns:
the width of the self
- Return type:
Returns the width that has currently been allocated to self. This function is intended to be used when implementing handlers for the
Gtk.Widget
::draw
function.
- get_allocation()[source]¶
- Returns:
a pointer to a #GtkAllocation to copy to
- Return type:
allocation:
Gdk.Rectangle
Retrieves the widget’s allocation.
Note, when implementing a
Gtk.Container
: a widget’s allocation will be its “adjusted” allocation, that is, the widget’s parent container typically callsGtk.Widget.size_allocate
() with an allocation, and that allocation is then adjusted (to handle margin and alignment for example) before assignment to the widget.Gtk.Widget.get_allocation
() returns the adjusted allocation that was actually assigned to the widget. The adjusted allocation is guaranteed to be completely contained within theGtk.Widget.size_allocate
() allocation, however. So aGtk.Container
is guaranteed that its children stay inside the assigned bounds, but not that they have exactly the bounds the container assigned. There is no way to get the original allocation assigned byGtk.Widget.size_allocate
(), since it isn’t stored; if a container implementation needs that information it will have to track it itself.New in version 2.18.
- get_ancestor(widget_type)[source]¶
- Parameters:
widget_type (
GObject.GType
) – ancestor type- Returns:
the ancestor widget, or
None
if not found- Return type:
Gtk.Widget
orNone
Gets the first ancestor of self with type widget_type. For example,
gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)
gets the firstGtk.Box
that’s an ancestor of self. No reference will be added to the returned widget; it should not be unreferenced. See note about checking for a toplevelGtk.Window
in the docs forGtk.Widget.get_toplevel
().Note that unlike
Gtk.Widget.is_ancestor
(),Gtk.Widget.get_ancestor
() considers self to be an ancestor of itself.
- get_app_paintable()[source]¶
-
Determines whether the application intends to draw on the widget in an
Gtk.Widget
::draw
handler.See
Gtk.Widget.set_app_paintable
()New in version 2.18.
- get_can_default()[source]¶
-
Determines whether self can be a default widget. See
Gtk.Widget.set_can_default
().New in version 2.18.
- get_can_focus()[source]¶
-
Determines whether self can own the input focus. See
Gtk.Widget.set_can_focus
().New in version 2.18.
- get_child_requisition()[source]¶
- Returns:
a
Gtk.Requisition
to be filled in- Return type:
requisition:
Gtk.Requisition
This function is only for use in widget implementations. Obtains self->requisition, unless someone has forced a particular geometry on the widget (e.g. with
Gtk.Widget.set_size_request
()), in which case it returns that geometry instead of the widget’s requisition.This function differs from
Gtk.Widget.size_request
() in that it retrieves the last size request value from self->requisition, whileGtk.Widget.size_request
() actually calls the “size_request” method on self to compute the size request and fill in self->requisition, and only then returns self->requisition.Because this function does not call the “size_request” method, it can only be used when you know that self->requisition is up-to-date, that is,
Gtk.Widget.size_request
() has been called since the last time a resize was queued. In general, only container implementations have this information; applications should useGtk.Widget.size_request
().Deprecated since version 3.0: Use
Gtk.Widget.get_preferred_size
() instead.
- get_child_visible()[source]¶
-
Gets the value set with
Gtk.Widget.set_child_visible
(). If you feel a need to use this function, your code probably needs reorganization.This function is only useful for container implementations and never should be called by an application.
- get_clip()[source]¶
- Returns:
a pointer to a #GtkAllocation to copy to
- Return type:
clip:
Gdk.Rectangle
Retrieves the widget’s clip area.
The clip area is the area in which all of self's drawing will happen. Other toolkits call it the bounding box.
Historically, in GTK+ the clip area has been equal to the allocation retrieved via
Gtk.Widget.get_allocation
().New in version 3.14.
- get_clipboard(selection)[source]¶
- Parameters:
selection (
Gdk.Atom
) – aGdk.Atom
which identifies the clipboard to use. %GDK_SELECTION_CLIPBOARD gives the default clipboard. Another common value is %GDK_SELECTION_PRIMARY, which gives the primary X selection.- Returns:
the appropriate clipboard object. If no clipboard already exists, a new one will be created. Once a clipboard object has been created, it is persistent for all time.
- Return type:
Returns the clipboard object for the given selection to be used with self. self must have a
Gdk.Display
associated with it, so must be attached to a toplevel window.New in version 2.2.
- get_composite_name()[source]¶
- Returns:
the composite name of self, or
None
if self is not a composite child. The string should be freed when it is no longer needed.- Return type:
Obtains the composite name of a widget.
Deprecated since version 3.10: Use
Gtk.WidgetClass.set_template
(), or don’t use this API at all.
- get_device_enabled(device)[source]¶
- Parameters:
device (
Gdk.Device
) – aGdk.Device
- Returns:
True
is device is enabled for self- Return type:
Returns whether device can interact with self and its children. See
Gtk.Widget.set_device_enabled
().New in version 3.0.
- get_device_events(device)[source]¶
- Parameters:
device (
Gdk.Device
) – aGdk.Device
- Returns:
device event mask for self
- Return type:
Returns the events mask for the widget corresponding to an specific device. These are the events that the widget will receive when device operates on it.
New in version 3.0.
- get_direction()[source]¶
- Returns:
the reading direction for the widget.
- Return type:
Gets the reading direction for a particular widget. See
Gtk.Widget.set_direction
().
- get_display()[source]¶
- Returns:
the
Gdk.Display
for the toplevel for this widget.- Return type:
Get the
Gdk.Display
for the toplevel window associated with this widget. This function can only be called after the widget has been added to a widget hierarchy with aGtk.Window
at the top.In general, you should only create display specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.
New in version 2.2.
- get_double_buffered()[source]¶
-
Determines whether the widget is double buffered.
See
Gtk.Widget.set_double_buffered
()New in version 2.18.
- get_events()[source]¶
- Returns:
event mask for self
- Return type:
Returns the event mask (see
Gdk.EventMask
) for the widget. These are the events that the widget will receive.Note: Internally, the widget event mask will be the logical OR of the event mask set through
Gtk.Widget.set_events
() orGtk.Widget.add_events
(), and the event mask necessary to cater for everyGtk.EventController
created for the widget.
- get_focus_on_click()[source]¶
-
Returns whether the widget should grab focus when it is clicked with the mouse. See
Gtk.Widget.set_focus_on_click
().New in version 3.20.
- get_font_map()[source]¶
- Returns:
A
Pango.FontMap
, orNone
- Return type:
Gets the font map that has been set with
Gtk.Widget.set_font_map
().New in version 3.18.
- get_font_options()[source]¶
- Returns:
the
cairo.FontOptions
orNone
if not set- Return type:
Returns the
cairo.FontOptions
used for Pango rendering. When not set, the defaults font options for theGdk.Screen
will be used.New in version 3.18.
- get_frame_clock()[source]¶
- Returns:
a
Gdk.FrameClock
, orNone
if widget is unrealized- Return type:
Obtains the frame clock for a widget. The frame clock is a global “ticker” that can be used to drive animations and repaints. The most common reason to get the frame clock is to call
Gdk.FrameClock.get_frame_time
(), in order to get a time to use for animating. For example you might record the start of the animation with an initial value fromGdk.FrameClock.get_frame_time
(), and then update the animation by callingGdk.FrameClock.get_frame_time
() again during each repaint.Gdk.FrameClock.request_phase
() will result in a new frame on the clock, but won’t necessarily repaint any widgets. To repaint a widget, you have to useGtk.Widget.queue_draw
() which invalidates the widget (thus scheduling it to receive a draw on the next frame).Gtk.Widget.queue_draw
() will also end up requesting a frame on the appropriate frame clock.A widget’s frame clock will not change while the widget is mapped. Reparenting a widget (which implies a temporary unmap) can change the widget’s frame clock.
Unrealized widgets do not have a frame clock.
New in version 3.8.
- get_halign()[source]¶
- Returns:
the horizontal alignment of self
- Return type:
Gets the value of the
Gtk.Widget
:halign
property.For backwards compatibility reasons this method will never return
Gtk.Align.BASELINE
, but instead it will convert it toGtk.Align.FILL
. Baselines are not supported for horizontal alignment.
- get_has_tooltip()[source]¶
- Returns:
current value of has-tooltip on self.
- Return type:
Returns the current value of the has-tooltip property. See
Gtk.Widget
:has-tooltip
for more information.New in version 2.12.
- get_has_window()[source]¶
-
Determines whether self has a
Gdk.Window
of its own. SeeGtk.Widget.set_has_window
().New in version 2.18.
- get_hexpand()[source]¶
- Returns:
whether hexpand flag is set
- Return type:
Gets whether the widget would like any available extra horizontal space. When a user resizes a
Gtk.Window
, widgets with expand=:obj:True generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.Containers should use
Gtk.Widget.compute_expand
() rather than this function, to see whether a widget, or any of its children, has the expand flag set. If any child of a widget wants to expand, the parent may ask to expand also.This function only looks at the widget’s own hexpand flag, rather than computing whether the entire widget tree rooted at this widget wants to expand.
- get_hexpand_set()[source]¶
- Returns:
whether hexpand has been explicitly set
- Return type:
Gets whether
Gtk.Widget.set_hexpand
() has been used to explicitly set the expand flag on this widget.If hexpand is set, then it overrides any computed expand value based on child widgets. If hexpand is not set, then the expand value depends on whether any children of the widget would like to expand.
There are few reasons to use this function, but it’s here for completeness and consistency.
- get_margin_bottom()[source]¶
- Returns:
The bottom margin of self
- Return type:
Gets the value of the
Gtk.Widget
:margin-bottom
property.New in version 3.0.
- get_margin_end()[source]¶
- Returns:
The end margin of self
- Return type:
Gets the value of the
Gtk.Widget
:margin-end
property.New in version 3.12.
- get_margin_left()[source]¶
- Returns:
The left margin of self
- Return type:
Gets the value of the
Gtk.Widget
:margin-left
property.New in version 3.0.
Deprecated since version 3.12: Use
Gtk.Widget.get_margin_start
() instead.
- get_margin_right()[source]¶
- Returns:
The right margin of self
- Return type:
Gets the value of the
Gtk.Widget
:margin-right
property.New in version 3.0.
Deprecated since version 3.12: Use
Gtk.Widget.get_margin_end
() instead.
- get_margin_start()[source]¶
- Returns:
The start margin of self
- Return type:
Gets the value of the
Gtk.Widget
:margin-start
property.New in version 3.12.
- get_margin_top()[source]¶
- Returns:
The top margin of self
- Return type:
Gets the value of the
Gtk.Widget
:margin-top
property.New in version 3.0.
- get_modifier_mask(intent)[source]¶
- Parameters:
intent (
Gdk.ModifierIntent
) – the use case for the modifier mask- Returns:
the modifier mask used for intent.
- Return type:
Returns the modifier mask the self’s windowing system backend uses for a particular purpose.
See
Gdk.Keymap.get_modifier_mask
().New in version 3.4.
- get_modifier_style()[source]¶
- Returns:
the modifier style for the widget. This rc style is owned by the widget. If you want to keep a pointer to value this around, you must add a refcount using
GObject.Object.ref
().- Return type:
Returns the current modifier style for the widget. (As set by
Gtk.Widget.modify_style
().) If no style has previously set, a newGtk.RcStyle
will be created with all values unset, and set as the modifier style for the widget. If you make changes to this rc style, you must callGtk.Widget.modify_style
(), passing in the returned rc style, to make sure that your changes take effect.Caution: passing the style back to
Gtk.Widget.modify_style
() will normally end up destroying it, becauseGtk.Widget.modify_style
() copies the passed-in style and sets the copy as the new modifier style, thus dropping any reference to the old modifier style. Add a reference to the modifier style if you want to keep it alive.Deprecated since version 3.0: Use
Gtk.StyleContext
with a customGtk.StyleProvider
instead
- get_name()[source]¶
- Returns:
name of the widget. This string is owned by GTK+ and should not be modified or freed
- Return type:
Retrieves the name of a widget. See
Gtk.Widget.set_name
() for the significance of widget names.
- get_no_show_all()[source]¶
- Returns:
the current value of the “no-show-all” property.
- Return type:
Returns the current value of the
Gtk.Widget
:no-show-all
property, which determines whether calls toGtk.Widget.show_all
() will affect this widget.New in version 2.4.
- get_opacity()[source]¶
- Returns:
the requested opacity for this widget.
- Return type:
Fetches the requested opacity for this widget. See
Gtk.Widget.set_opacity
().New in version 3.8.
- get_pango_context()[source]¶
- Returns:
the
Pango.Context
for the widget.- Return type:
Gets a
Pango.Context
with the appropriate font map, font description, and base direction for this widget. Unlike the context returned byGtk.Widget.create_pango_context
(), this context is owned by the widget (it can be used until the screen for the widget changes or the widget is removed from its toplevel), and will be updated to match any changes to the widget’s attributes. This can be tracked by using theGtk.Widget
::screen-changed
signal on the widget.
- get_parent()[source]¶
- Returns:
the parent container of self, or
None
- Return type:
Gtk.Widget
orNone
Returns the parent container of self.
- get_parent_window()[source]¶
- Returns:
the parent window of self, or
None
if it does not have a parent window.- Return type:
Gdk.Window
orNone
Gets self’s parent window, or
None
if it does not have one.
- get_path()[source]¶
- Returns:
The
Gtk.WidgetPath
representing self- Return type:
Returns the
Gtk.WidgetPath
representing self, if the widget is not connected to a toplevel widget, a partial path will be created.
- get_pointer()[source]¶
- Returns:
- Return type:
Obtains the location of the mouse pointer in widget coordinates. Widget coordinates are a bit odd; for historical reasons, they are defined as self->window coordinates for widgets that return
True
forGtk.Widget.get_has_window
(); and are relative to self->allocation.x, self->allocation.y otherwise.Deprecated since version 3.4: Use
Gdk.Window.get_device_position
() instead.
- get_preferred_height()[source]¶
- Returns:
- Return type:
Retrieves a widget’s initial minimum and natural height.
This call is specific to width-for-height requests.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any
Gtk.SizeGroups
that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.New in version 3.0.
- get_preferred_height_and_baseline_for_width(width)[source]¶
- Parameters:
width (
int
) – the width which is available for allocation, or -1 if none- Returns:
- Return type:
(minimum_height:
int
, natural_height:int
, minimum_baseline:int
, natural_baseline:int
)
Retrieves a widget’s minimum and natural height and the corresponding baselines if it would be given the specified width, or the default height if width is -1. The baselines may be -1 which means that no baseline is requested for this widget.
The returned request will be modified by the GtkWidgetClass::adjust_size_request and GtkWidgetClass::adjust_baseline_request virtual methods and by any
Gtk.SizeGroups
that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.New in version 3.10.
- get_preferred_height_for_width(width)[source]¶
- Parameters:
width (
int
) – the width which is available for allocation- Returns:
- Return type:
Retrieves a widget’s minimum and natural height if it would be given the specified width.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any
Gtk.SizeGroups
that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.New in version 3.0.
- get_preferred_size()[source]¶
- Returns:
- Return type:
(minimum_size:
Gtk.Requisition
, natural_size:Gtk.Requisition
)
Retrieves the minimum and natural size of a widget, taking into account the widget’s preference for height-for-width management.
This is used to retrieve a suitable size by container widgets which do not impose any restrictions on the child placement. It can be used to deduce toplevel window and menu sizes as well as child widgets in free-form containers such as
Gtk.Layout
.Handle with care. Note that the natural height of a height-for-width widget will generally be a smaller size than the minimum height, since the required height for the natural width is generally smaller than the required height for the minimum width.
Use
Gtk.Widget.get_preferred_height_and_baseline_for_width
() if you want to support baseline alignment.New in version 3.0.
- get_preferred_width()[source]¶
- Returns:
- Return type:
Retrieves a widget’s initial minimum and natural width.
This call is specific to height-for-width requests.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any
Gtk.SizeGroups
that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.New in version 3.0.
- get_preferred_width_for_height(height)[source]¶
- Parameters:
height (
int
) – the height which is available for allocation- Returns:
- Return type:
Retrieves a widget’s minimum and natural width if it would be given the specified height.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any
Gtk.SizeGroups
that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.New in version 3.0.
- get_receives_default()[source]¶
-
Determines whether self is always treated as the default widget within its toplevel when it has the focus, even if another widget is the default.
See
Gtk.Widget.set_receives_default
().New in version 2.18.
- get_request_mode()[source]¶
- Returns:
The
Gtk.SizeRequestMode
preferred by self.- Return type:
Gets whether the widget prefers a height-for-width layout or a width-for-height layout.
Gtk.Bin
widgets generally propagate the preference of their child, container widgets need to request something either in context of their children or in context of their allocation capabilities.New in version 3.0.
- get_requisition()[source]¶
- Returns:
a pointer to a
Gtk.Requisition
to copy to- Return type:
requisition:
Gtk.Requisition
Retrieves the widget’s requisition.
This function should only be used by widget implementations in order to figure whether the widget’s requisition has actually changed after some internal state change (so that they can call
Gtk.Widget.queue_resize
() instead ofGtk.Widget.queue_draw
()).Normally,
Gtk.Widget.size_request
() should be used.New in version 2.20.
Deprecated since version 3.0: The
Gtk.Requisition
cache on the widget was removed, If you need to cache sizes across requests and allocations, add an explicit cache to the widget in question instead.
- get_root_window()[source]¶
- Returns:
the
Gdk.Window
root window for the toplevel for this widget.- Return type:
Get the root window where this widget is located. This function can only be called after the widget has been added to a widget hierarchy with
Gtk.Window
at the top.The root window is useful for such purposes as creating a popup
Gdk.Window
associated with the window. In general, you should only create display specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.New in version 2.2.
Deprecated since version 3.12: Use
Gdk.Screen.get_root_window
() instead
- get_scale_factor()[source]¶
- Returns:
the scale factor for self
- Return type:
Retrieves the internal scale factor that maps from window coordinates to the actual device pixels. On traditional systems this is 1, on high density outputs, it can be a higher value (typically 2).
See
Gdk.Window.get_scale_factor
().New in version 3.10.
- get_screen()[source]¶
- Returns:
the
Gdk.Screen
for the toplevel for this widget.- Return type:
Get the
Gdk.Screen
from the toplevel window associated with this widget. This function can only be called after the widget has been added to a widget hierarchy with aGtk.Window
at the top.In general, you should only create screen specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.
New in version 2.2.
- get_sensitive()[source]¶
-
Returns the widget’s sensitivity (in the sense of returning the value that has been set using
Gtk.Widget.set_sensitive
()).The effective sensitivity of a widget is however determined by both its own and its parent widget’s sensitivity. See
Gtk.Widget.is_sensitive
().New in version 2.18.
- get_settings()[source]¶
- Returns:
the relevant
Gtk.Settings
object- Return type:
Gets the settings object holding the settings used for this widget.
Note that this function can only be called when the
Gtk.Widget
is attached to a toplevel, since the settings object is specific to a particularGdk.Screen
.
- get_size_request()[source]¶
- Returns:
- Return type:
Gets the size request that was explicitly set for the widget using
Gtk.Widget.set_size_request
(). A value of -1 stored in width or height indicates that that dimension has not been set explicitly and the natural requisition of the widget will be used instead. SeeGtk.Widget.set_size_request
(). To get the size a widget will actually request, callGtk.Widget.get_preferred_size
() instead of this function.
- get_state()[source]¶
- Returns:
the state of self.
- Return type:
Returns the widget’s state. See
Gtk.Widget.set_state
().New in version 2.18.
Deprecated since version 3.0: Use
Gtk.Widget.get_state_flags
() instead.
- get_state_flags()[source]¶
- Returns:
The state flags for widget
- Return type:
Returns the widget state as a flag set. It is worth mentioning that the effective
Gtk.StateFlags.INSENSITIVE
state will be returned, that is, also based on parent insensitivity, even if self itself is sensitive.Also note that if you are looking for a way to obtain the
Gtk.StateFlags
to pass to aGtk.StyleContext
method, you should look atGtk.StyleContext.get_state
().New in version 3.0.
- get_style()[source]¶
-
Simply an accessor function that returns self->style.
Deprecated since version 3.0: Use
Gtk.StyleContext
instead
- get_style_context()[source]¶
- Returns:
a
Gtk.StyleContext
. This memory is owned by self and must not be freed.- Return type:
Returns the style context associated to self. The returned object is guaranteed to be the same for the lifetime of self.
- get_support_multidevice()[source]¶
-
Returns
True
if self is multiple pointer aware. SeeGtk.Widget.set_support_multidevice
() for more information.
- get_template_child(widget_type, name)[source]¶
- Parameters:
widget_type (
GObject.GType
) – TheGObject.GType
to get a template child forname (
str
) – The “id” of the child defined in the template XML
- Returns:
The object built in the template XML with the id name
- Return type:
Fetch an object build from the template XML for widget_type in this self instance.
This will only report children which were previously declared with
Gtk.WidgetClass.bind_template_child_full
() or one of its variants.This function is only meant to be called for code which is private to the widget_type which declared the child and is meant for language bindings which cannot easily make use of the
GObject.Object
structure offsets.
- get_tooltip_markup()[source]¶
- Returns:
the tooltip text, or
None
. You should free the returned string withGLib.free
() when done.- Return type:
Gets the contents of the tooltip for self.
New in version 2.12.
- get_tooltip_text()[source]¶
- Returns:
the tooltip text, or
None
. You should free the returned string withGLib.free
() when done.- Return type:
Gets the contents of the tooltip for self.
New in version 2.12.
- get_tooltip_window()[source]¶
- Returns:
The
Gtk.Window
of the current tooltip.- Return type:
Returns the
Gtk.Window
of the current tooltip. This can be theGtk.Window
created by default, or the custom tooltip window set usingGtk.Widget.set_tooltip_window
().New in version 2.12.
- get_toplevel()[source]¶
- Returns:
the topmost ancestor of self, or self itself if there’s no ancestor.
- Return type:
This function returns the topmost widget in the container hierarchy self is a part of. If self has no parent widgets, it will be returned as the topmost widget. No reference will be added to the returned widget; it should not be unreferenced.
Note the difference in behavior vs.
Gtk.Widget.get_ancestor
();gtk_widget_get_ancestor (widget, GTK_TYPE_WINDOW)
would returnNone
if self wasn’t inside a toplevel window, and if the window was inside aGtk.Window
-derived widget which was in turn inside the toplevelGtk.Window
. While the second case may seem unlikely, it actually happens when aGtk.Plug
is embedded inside aGtk.Socket
within the same application.To reliably find the toplevel
Gtk.Window
, useGtk.Widget.get_toplevel
() and call GTK_IS_WINDOW() on the result. For instance, to get the title of a widget’s toplevel window, one might use:static const char * get_widget_toplevel_title (GtkWidget *widget) { GtkWidget *toplevel = gtk_widget_get_toplevel (widget); if (GTK_IS_WINDOW (toplevel)) { return gtk_window_get_title (GTK_WINDOW (toplevel)); } return NULL; }
- get_valign()[source]¶
- Returns:
the vertical alignment of self, ignoring baseline alignment
- Return type:
Gets the value of the
Gtk.Widget
:valign
property.For backwards compatibility reasons this method will never return
Gtk.Align.BASELINE
, but instead it will convert it toGtk.Align.FILL
. If your widget want to support baseline aligned children it must useGtk.Widget.get_valign_with_baseline
(), org_object_get (widget, "valign", &value, NULL)
, which will also report the true value.
- get_valign_with_baseline()[source]¶
- Returns:
the vertical alignment of self
- Return type:
Gets the value of the
Gtk.Widget
:valign
property, includingGtk.Align.BASELINE
.New in version 3.10.
- get_vexpand()[source]¶
- Returns:
whether vexpand flag is set
- Return type:
Gets whether the widget would like any available extra vertical space.
See
Gtk.Widget.get_hexpand
() for more detail.
- get_vexpand_set()[source]¶
- Returns:
whether vexpand has been explicitly set
- Return type:
Gets whether
Gtk.Widget.set_vexpand
() has been used to explicitly set the expand flag on this widget.See
Gtk.Widget.get_hexpand_set
() for more detail.
- get_visible()[source]¶
-
Determines whether the widget is visible. If you want to take into account whether the widget’s parent is also marked as visible, use
Gtk.Widget.is_visible
() instead.This function does not check if the widget is obscured in any way.
See
Gtk.Widget.set_visible
().New in version 2.18.
- get_visual()[source]¶
- Returns:
the visual for self
- Return type:
Gets the visual that will be used to render self.
- get_window()[source]¶
- Returns:
self’s window.
- Return type:
Gdk.Window
orNone
Returns the widget’s window if it is realized,
None
otherwiseNew in version 2.14.
- grab_add()[source]¶
Makes self the current grabbed widget.
This means that interaction with other widgets in the same application is blocked and mouse as well as keyboard events are delivered to this widget.
If self is not sensitive, it is not set as the current grabbed widget and this function does nothing.
- grab_default()[source]¶
Causes self to become the default widget. self must be able to be a default widget; typically you would ensure this yourself by calling
Gtk.Widget.set_can_default
() with aTrue
value. The default widget is activated when the user presses Enter in a window. Default widgets must be activatable, that is,Gtk.Widget.activate
() should affect them. Note thatGtk.Entry
widgets require the “activates-default” property set toTrue
before they activate the default widget when Enter is pressed and theGtk.Entry
is focused.
- grab_focus()[source]¶
Causes self to have the keyboard focus for the
Gtk.Window
it’s inside. self must be a focusable widget, such as aGtk.Entry
; something likeGtk.Frame
won’t work.More precisely, it must have the %GTK_CAN_FOCUS flag set. Use
Gtk.Widget.set_can_focus
() to modify that flag.The widget also needs to be realized and mapped. This is indicated by the related signals. Grabbing the focus immediately after creating the widget will likely fail and cause critical warnings.
- grab_remove()[source]¶
Removes the grab from the given widget.
You have to pair calls to
Gtk.Widget.grab_add
() andGtk.Widget.grab_remove
().If self does not have the grab, this function does nothing.
- has_default()[source]¶
- Returns:
True
if self is the current default widget within its toplevel,False
otherwise- Return type:
Determines whether self is the current default widget within its toplevel. See
Gtk.Widget.set_can_default
().New in version 2.18.
- has_focus()[source]¶
-
Determines if the widget has the global input focus. See
Gtk.Widget.is_focus
() for the difference between having the global input focus, and only having the focus within a toplevel.New in version 2.18.
- has_grab()[source]¶
-
Determines whether the widget is currently grabbing events, so it is the only widget receiving input events (keyboard and mouse).
See also
Gtk.Widget.grab_add
().New in version 2.18.
- has_rc_style()[source]¶
- Returns:
True
if the widget has been looked up through the rc mechanism,False
otherwise.- Return type:
Determines if the widget style has been looked up through the rc mechanism.
New in version 2.20.
Deprecated since version 3.0: Use
Gtk.StyleContext
instead
- has_screen()[source]¶
- Returns:
True
if there is aGdk.Screen
associated with the widget.- Return type:
Checks whether there is a
Gdk.Screen
is associated with this widget. All toplevel widgets have an associated screen, and all widgets added into a hierarchy with a toplevel window at the top.New in version 2.2.
- has_visible_focus()[source]¶
-
Determines if the widget should show a visible indication that it has the global input focus. This is a convenience function for use in
::draw
handlers that takes into account whether focus indication should currently be shown in the toplevel window of self. SeeGtk.Window.get_focus_visible
() for more information about focus indication.To find out if the widget has the global input focus, use
Gtk.Widget.has_focus
().New in version 3.2.
- hide()[source]¶
Reverses the effects of
Gtk.Widget.show
(), causing the widget to be hidden (invisible to the user).
- hide_on_delete()[source]¶
-
Utility function; intended to be connected to the
Gtk.Widget
::delete-event
signal on aGtk.Window
. The function callsGtk.Widget.hide
() on its argument, then returnsTrue
. If connected to::delete-event
, the result is that clicking the close button for a window (on the window frame, top right corner usually) will hide but not destroy the window. By default, GTK+ destroys windows when::delete-event
is received.
- in_destruction()[source]¶
-
Returns whether the widget is currently being destroyed. This information can sometimes be used to avoid doing unnecessary work.
- init_template()[source]¶
Creates and initializes child widgets defined in templates. This function must be called in the instance initializer for any class which assigned itself a template using
Gtk.WidgetClass.set_template
()It is important to call this function in the instance initializer of a
Gtk.Widget
subclass and not inGObject.Object.do_constructed
() orGObject.Object.do_constructor
() for two reasons.One reason is that generally derived widgets will assume that parent class composite widgets have been created in their instance initializers.
Another reason is that when calling g_object_new() on a widget with composite templates, it’s important to build the composite widgets before the construct properties are set. Properties passed to g_object_new() should take precedence over properties set in the private template XML.
New in version 3.10.
- input_shape_combine_region(region)[source]¶
- Parameters:
region (
cairo.Region
orNone
) – shape to be added, orNone
to remove an existing shape
Sets an input shape for this widget’s GDK window. This allows for windows which react to mouse click in a nonrectangular region, see
Gdk.Window.input_shape_combine_region
() for more information.New in version 3.0.
- insert_action_group(name, group)[source]¶
- Parameters:
name (
str
) – the prefix for actions in groupgroup (
Gio.ActionGroup
orNone
) – aGio.ActionGroup
, orNone
Inserts group into self. Children of self that implement
Gtk.Actionable
can then be associated with actions in group by setting their “action-name” to prefix.``action-name``.If group is
None
, a previously inserted group for name is removed from self.New in version 3.6.
- intersect(area)[source]¶
- Parameters:
area (
Gdk.Rectangle
) – a rectangle- Returns:
True
if there was an intersection- intersection:
rectangle to store intersection of self and area
- Return type:
(
bool
, intersection:Gdk.Rectangle
)
Computes the intersection of a self’s area and area, storing the intersection in intersection, and returns
True
if there was an intersection. intersection may beNone
if you’re only interested in whether there was an intersection.
- is_ancestor(ancestor)[source]¶
- Parameters:
ancestor (
Gtk.Widget
) – anotherGtk.Widget
- Returns:
True
if ancestor contains self as a child, grandchild, great grandchild, etc.- Return type:
Determines whether self is somewhere inside ancestor, possibly with intermediate containers.
- is_composited()[source]¶
-
Whether self can rely on having its alpha channel drawn correctly. On X11 this function returns whether a compositing manager is running for self’s screen.
Please note that the semantics of this call will change in the future if used on a widget that has a composited window in its hierarchy (as set by
Gdk.Window.set_composited
()).New in version 2.10.
Deprecated since version 3.22: Use
Gdk.Screen.is_composited
() instead.
- is_drawable()[source]¶
-
Determines whether self can be drawn to. A widget can be drawn to if it is mapped and visible.
New in version 2.18.
- is_focus()[source]¶
-
Determines if the widget is the focus widget within its toplevel. (This does not mean that the
Gtk.Widget
:has-focus
property is necessarily set;Gtk.Widget
:has-focus
will only be set if the toplevel widget additionally has the global input focus.)
- is_sensitive()[source]¶
-
Returns the widget’s effective sensitivity, which means it is sensitive itself and also its parent widget is sensitive
New in version 2.18.
- is_toplevel()[source]¶
-
Determines whether self is a toplevel widget.
Currently only
Gtk.Window
andGtk.Invisible
(and out-of-processGtk.Plugs
) are toplevel widgets. Toplevel widgets have no parent widget.New in version 2.18.
- is_visible()[source]¶
-
Determines whether the widget and all its parents are marked as visible.
This function does not check if the widget is obscured in any way.
See also
Gtk.Widget.get_visible
() andGtk.Widget.set_visible
()New in version 3.8.
- Parameters:
direction (
Gtk.DirectionType
) – direction of focus movement- Returns:
True
if stopping keyboard navigation is fine,False
if the emitting widget should try to handle the keyboard navigation attempt in its parent container(s).- Return type:
This function should be called whenever keyboard navigation within a single widget hits a boundary. The function emits the
Gtk.Widget
::keynav-failed
signal on the widget and its return value should be interpreted in a way similar to the return value ofGtk.Widget.child_focus
():When
True
is returned, stay in the widget, the failed keyboard navigation is OK and/or there is nowhere we can/should move the focus to.When
False
is returned, the caller should continue with keyboard navigation outside the widget, e.g. by callingGtk.Widget.child_focus
() on the widget’s toplevel.The default
::keynav-failed
handler returnsFalse
forGtk.DirectionType.TAB_FORWARD
andGtk.DirectionType.TAB_BACKWARD
. For the other values ofGtk.DirectionType
it returnsTrue
.Whenever the default handler returns
True
, it also callsGtk.Widget.error_bell
() to notify the user of the failed keyboard navigation.A use case for providing an own implementation of
::keynav-failed
(either by connecting to it or by overriding it) would be a row ofGtk.Entry
widgets where the user should be able to navigate the entire row with the cursor keys, as e.g. known from user interfaces that require entering license keys.New in version 2.12.
- list_accel_closures()[source]¶
- Returns:
a newly allocated
GLib.List
of closures- Return type:
Lists the closures used by self for accelerator group connections with
Gtk.AccelGroup.connect_by_path
() orGtk.AccelGroup.connect
(). The closures can be used to monitor accelerator changes on self, by connecting to the GtkAccelGroup::accel-changed
signal of theGtk.AccelGroup
of a closure which can be found out withGtk.AccelGroup.from_accel_closure
().
- list_action_prefixes()[source]¶
-
Retrieves a
None
-terminated array of strings containing the prefixes ofGio.ActionGroup
's available to self.New in version 3.16.
- list_mnemonic_labels()[source]¶
- Returns:
the list of mnemonic labels; free this list with g_list_free() when you are done with it.
- Return type:
Returns a newly allocated list of the widgets, normally labels, for which this widget is the target of a mnemonic (see for example,
Gtk.Label.set_mnemonic_widget
()).The widgets in the list are not individually referenced. If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets, you must call
g_list_foreach (result, (GFunc)g_object_ref, NULL)
first, and then unref all the widgets afterwards.New in version 2.4.
- map()[source]¶
This function is only for use in widget implementations. Causes a widget to be mapped if it isn’t already.
- mnemonic_activate(group_cycling)[source]¶
- Parameters:
group_cycling (
bool
) –True
if there are other widgets with the same mnemonic- Returns:
True
if the signal has been handled- Return type:
Emits the
Gtk.Widget
::mnemonic-activate
signal.
- modify_base(state, color)[source]¶
- Parameters:
state (
Gtk.StateType
) – the state for which to set the base colorcolor (
Gdk.Color
orNone
) – the color to assign (does not need to be allocated), orNone
to undo the effect of previous calls to ofGtk.Widget.modify_base
().
Sets the base color for a widget in a particular state. All other style values are left untouched. The base color is the background color used along with the text color (see
Gtk.Widget.modify_text
()) for widgets such asGtk.Entry
andGtk.TextView
. See alsoGtk.Widget.modify_style
().Note that “no window” widgets (which have the %GTK_NO_WINDOW flag set) draw on their parent container’s window and thus may not draw any background themselves. This is the case for e.g.
Gtk.Label
.To modify the background of such widgets, you have to set the base color on their parent; if you want to set the background of a rectangular area around a label, try placing the label in a
Gtk.EventBox
widget and setting the base color on that.Deprecated since version 3.0: Use
Gtk.Widget.override_background_color
() instead
- modify_bg(state, color)[source]¶
- Parameters:
state (
Gtk.StateType
) – the state for which to set the background colorcolor (
Gdk.Color
orNone
) – the color to assign (does not need to be allocated), orNone
to undo the effect of previous calls to ofGtk.Widget.modify_bg
().
Sets the background color for a widget in a particular state.
All other style values are left untouched. See also
Gtk.Widget.modify_style
().Note that “no window” widgets (which have the %GTK_NO_WINDOW flag set) draw on their parent container’s window and thus may not draw any background themselves. This is the case for e.g.
Gtk.Label
.To modify the background of such widgets, you have to set the background color on their parent; if you want to set the background of a rectangular area around a label, try placing the label in a
Gtk.EventBox
widget and setting the background color on that.Deprecated since version 3.0: Use
Gtk.Widget.override_background_color
() instead
- modify_cursor(primary, secondary)[source]¶
- Parameters:
primary (
Gdk.Color
orNone
) – the color to use for primary cursor (does not need to be allocated), orNone
to undo the effect of previous calls to ofGtk.Widget.modify_cursor
().secondary (
Gdk.Color
orNone
) – the color to use for secondary cursor (does not need to be allocated), orNone
to undo the effect of previous calls to ofGtk.Widget.modify_cursor
().
Sets the cursor color to use in a widget, overriding the
Gtk.Widget
cursor-color and secondary-cursor-color style properties.All other style values are left untouched. See also
Gtk.Widget.modify_style
().New in version 2.12.
Deprecated since version 3.0: Use
Gtk.Widget.override_cursor
() instead.
- modify_fg(state, color)[source]¶
- Parameters:
state (
Gtk.StateType
) – the state for which to set the foreground colorcolor (
Gdk.Color
orNone
) – the color to assign (does not need to be allocated), orNone
to undo the effect of previous calls to ofGtk.Widget.modify_fg
().
Sets the foreground color for a widget in a particular state.
All other style values are left untouched. See also
Gtk.Widget.modify_style
().Deprecated since version 3.0: Use
Gtk.Widget.override_color
() instead
- modify_font(font_desc)[source]¶
- Parameters:
font_desc (
Pango.FontDescription
orNone
) – the font description to use, orNone
to undo the effect of previous calls toGtk.Widget.modify_font
()
Sets the font to use for a widget.
All other style values are left untouched. See also
Gtk.Widget.modify_style
().Deprecated since version 3.0: Use
Gtk.Widget.override_font
() instead
- modify_style(style)[source]¶
- Parameters:
style (
Gtk.RcStyle
) – theGtk.RcStyle
-struct holding the style modifications
Modifies style values on the widget.
Modifications made using this technique take precedence over style values set via an RC file, however, they will be overridden if a style is explicitly set on the widget using
Gtk.Widget.set_style
(). TheGtk.RcStyle
-struct is designed so each field can either be set or unset, so it is possible, using this function, to modify some style values and leave the others unchanged.Note that modifications made with this function are not cumulative with previous calls to
Gtk.Widget.modify_style
() or with such functions asGtk.Widget.modify_fg
(). If you wish to retain previous values, you must first callGtk.Widget.get_modifier_style
(), make your modifications to the returned style, then callGtk.Widget.modify_style
() with that style. On the other hand, if you first callGtk.Widget.modify_style
(), subsequent calls to such functionsGtk.Widget.modify_fg
() will have a cumulative effect with the initial modifications.Deprecated since version 3.0: Use
Gtk.StyleContext
with a customGtk.StyleProvider
instead
- modify_text(state, color)[source]¶
- Parameters:
state (
Gtk.StateType
) – the state for which to set the text colorcolor (
Gdk.Color
orNone
) – the color to assign (does not need to be allocated), orNone
to undo the effect of previous calls to ofGtk.Widget.modify_text
().
Sets the text color for a widget in a particular state.
All other style values are left untouched. The text color is the foreground color used along with the base color (see
Gtk.Widget.modify_base
()) for widgets such asGtk.Entry
andGtk.TextView
. See alsoGtk.Widget.modify_style
().Deprecated since version 3.0: Use
Gtk.Widget.override_color
() instead
- override_background_color(state, color)[source]¶
- Parameters:
state (
Gtk.StateFlags
) – the state for which to set the background colorcolor (
Gdk.RGBA
orNone
) – the color to assign, orNone
to undo the effect of previous calls toGtk.Widget.override_background_color
()
Sets the background color to use for a widget.
All other style values are left untouched. See
Gtk.Widget.override_color
().New in version 3.0.
Deprecated since version 3.16: This function is not useful in the context of CSS-based rendering. If you wish to change the way a widget renders its background you should use a custom CSS style, through an application-specific
Gtk.StyleProvider
and a CSS style class. You can also override the default drawing of a widget through theGtk.Widget
::draw
signal, and use Cairo to draw a specific color, regardless of the CSS style.
- override_color(state, color)[source]¶
- Parameters:
state (
Gtk.StateFlags
) – the state for which to set the colorcolor (
Gdk.RGBA
orNone
) – the color to assign, orNone
to undo the effect of previous calls toGtk.Widget.override_color
()
Sets the color to use for a widget.
All other style values are left untouched.
This function does not act recursively. Setting the color of a container does not affect its children. Note that some widgets that you may not think of as containers, for instance
Gtk.Buttons
, are actually containers.This API is mostly meant as a quick way for applications to change a widget appearance. If you are developing a widgets library and intend this change to be themeable, it is better done by setting meaningful CSS classes in your widget/container implementation through
Gtk.StyleContext.add_class
().This way, your widget library can install a
Gtk.CssProvider
with theGtk.STYLE_PROVIDER_PRIORITY_FALLBACK
priority in order to provide a default styling for those widgets that need so, and this theming may fully overridden by the user’s theme.Note that for complex widgets this may bring in undesired results (such as uniform background color everywhere), in these cases it is better to fully style such widgets through a
Gtk.CssProvider
with theGtk.STYLE_PROVIDER_PRIORITY_APPLICATION
priority.New in version 3.0.
Deprecated since version 3.16: Use a custom style provider and style classes instead
- override_cursor(cursor, secondary_cursor)[source]¶
- Parameters:
cursor (
Gdk.RGBA
orNone
) – the color to use for primary cursor (does not need to be allocated), orNone
to undo the effect of previous calls to ofGtk.Widget.override_cursor
().secondary_cursor (
Gdk.RGBA
orNone
) – the color to use for secondary cursor (does not need to be allocated), orNone
to undo the effect of previous calls to ofGtk.Widget.override_cursor
().
Sets the cursor color to use in a widget, overriding the cursor-color and secondary-cursor-color style properties. All other style values are left untouched. See also
Gtk.Widget.modify_style
().Note that the underlying properties have the
Gdk.Color
type, so the alpha value in primary and secondary will be ignored.New in version 3.0.
Deprecated since version 3.16: This function is not useful in the context of CSS-based rendering. If you wish to change the color used to render the primary and secondary cursors you should use a custom CSS style, through an application-specific
Gtk.StyleProvider
and a CSS style class.
- override_font(font_desc)[source]¶
- Parameters:
font_desc (
Pango.FontDescription
orNone
) – the font description to use, orNone
to undo the effect of previous calls toGtk.Widget.override_font
()
Sets the font to use for a widget. All other style values are left untouched. See
Gtk.Widget.override_color
().New in version 3.0.
Deprecated since version 3.16: This function is not useful in the context of CSS-based rendering. If you wish to change the font a widget uses to render its text you should use a custom CSS style, through an application-specific
Gtk.StyleProvider
and a CSS style class.
- override_symbolic_color(name, color)[source]¶
- Parameters:
name (
str
) – the name of the symbolic color to modifycolor (
Gdk.RGBA
orNone
) – the color to assign (does not need to be allocated), orNone
to undo the effect of previous calls toGtk.Widget.override_symbolic_color
()
Sets a symbolic color for a widget.
All other style values are left untouched. See
Gtk.Widget.override_color
() for overriding the foreground or background color.New in version 3.0.
Deprecated since version 3.16: This function is not useful in the context of CSS-based rendering. If you wish to change the color used to render symbolic icons you should use a custom CSS style, through an application-specific
Gtk.StyleProvider
and a CSS style class.
- path()[source]¶
- Returns:
- Return type:
Obtains the full path to self. The path is simply the name of a widget and all its parents in the container hierarchy, separated by periods. The name of a widget comes from
Gtk.Widget.get_name
(). Paths are used to apply styles to a widget in gtkrc configuration files. Widget names are the type of the widget by default (e.g. “Gtk.Button
”) or can be set to an application-specific value withGtk.Widget.set_name
(). By setting the name of a widget, you allow users or theme authors to apply styles to that specific widget in their gtkrc file. path_reversed_p fills in the path in reverse order, i.e. starting with self’s name instead of starting with the name of self’s outermost ancestor.Deprecated since version 3.0: Use
Gtk.Widget.get_path
() instead
- queue_allocate()[source]¶
This function is only for use in widget implementations.
Flags the widget for a rerun of the GtkWidgetClass::size_allocate function. Use this function instead of
Gtk.Widget.queue_resize
() when the self's size request didn’t change but it wants to reposition its contents.An example user of this function is
Gtk.Widget.set_halign
().New in version 3.20.
- queue_compute_expand()[source]¶
Mark self as needing to recompute its expand flags. Call this function when setting legacy expand child properties on the child of a container.
See
Gtk.Widget.compute_expand
().
- queue_draw()[source]¶
Equivalent to calling
Gtk.Widget.queue_draw_area
() for the entire area of a widget.
- queue_draw_area(x, y, width, height)[source]¶
- Parameters:
Convenience function that calls
Gtk.Widget.queue_draw_region
() on the region created from the given coordinates.The region here is specified in widget coordinates. Widget coordinates are a bit odd; for historical reasons, they are defined as self->window coordinates for widgets that return
True
forGtk.Widget.get_has_window
(), and are relative to self->allocation.x, self->allocation.y otherwise.width or height may be 0, in this case this function does nothing. Negative values for width and height are not allowed.
- queue_draw_region(region)[source]¶
- Parameters:
region (
cairo.Region
) – region to draw
Invalidates the area of self defined by region by calling
Gdk.Window.invalidate_region
() on the widget’s window and all its child windows. Once the main loop becomes idle (after the current batch of events has been processed, roughly), the window will receive expose events for the union of all regions that have been invalidated.Normally you would only use this function in widget implementations. You might also use it to schedule a redraw of a
Gtk.DrawingArea
or some portion thereof.New in version 3.0.
- queue_resize()[source]¶
This function is only for use in widget implementations. Flags a widget to have its size renegotiated; should be called when a widget for some reason has a new size request. For example, when you change the text in a
Gtk.Label
,Gtk.Label
queues a resize to ensure there’s enough space for the new text.Note that you cannot call
Gtk.Widget.queue_resize
() on a widget from inside its implementation of the GtkWidgetClass::size_allocate virtual method. Calls toGtk.Widget.queue_resize
() from inside GtkWidgetClass::size_allocate will be silently ignored.
- queue_resize_no_redraw()[source]¶
This function works like
Gtk.Widget.queue_resize
(), except that the widget is not invalidated.New in version 2.4.
- realize()[source]¶
Creates the GDK (windowing system) resources associated with a widget. For example, self->window will be created when a widget is realized. Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and mapped automatically.
Realizing a widget requires all the widget’s parent widgets to be realized; calling
Gtk.Widget.realize
() realizes the widget’s parents in addition to self itself. If a widget is not yet inside a toplevel window when you realize it, bad things will happen.This function is primarily used in widget implementations, and isn’t very useful otherwise. Many times when you think you might need it, a better approach is to connect to a signal that will be called after the widget is realized automatically, such as
Gtk.Widget
::draw
. Or simply g_signal_connect () to theGtk.Widget
::realize
signal.
- region_intersect(region)[source]¶
- Parameters:
region (
cairo.Region
) – acairo.Region
, in the same coordinate system as self->allocation. That is, relative to self->window for widgets which returnFalse
fromGtk.Widget.get_has_window
(); relative to the parent window of self->window otherwise.- Returns:
A newly allocated region holding the intersection of self and region.
- Return type:
Computes the intersection of a self’s area and region, returning the intersection. The result may be empty, use cairo_region_is_empty() to check.
Deprecated since version 3.14: Use
Gtk.Widget.get_allocation
() and cairo_region_intersect_rectangle() to get the same behavior.
- register_window(window)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
Registers a
Gdk.Window
with the widget and sets it up so that the widget receives events for it. CallGtk.Widget.unregister_window
() when destroying the window.Before 3.8 you needed to call
Gdk.Window.set_user_data
() directly to set this up. This is now deprecated and you should useGtk.Widget.register_window
() instead. Old code will keep working as is, although some new features like transparency might not work perfectly.New in version 3.8.
- remove_accelerator(accel_group, accel_key, accel_mods)[source]¶
- Parameters:
accel_group (
Gtk.AccelGroup
) – accel group for this widgetaccel_key (
int
) – GDK keyval of the acceleratoraccel_mods (
Gdk.ModifierType
) – modifier key combination of the accelerator
- Returns:
whether an accelerator was installed and could be removed
- Return type:
Removes an accelerator from self, previously installed with
Gtk.Widget.add_accelerator
().
- remove_mnemonic_label(label)[source]¶
- Parameters:
label (
Gtk.Widget
) – aGtk.Widget
that was previously set as a mnemonic label for self withGtk.Widget.add_mnemonic_label
().
Removes a widget from the list of mnemonic labels for this widget. (See
Gtk.Widget.list_mnemonic_labels
()). The widget must have previously been added to the list withGtk.Widget.add_mnemonic_label
().New in version 2.4.
- remove_tick_callback(id)[source]¶
- Parameters:
id (
int
) – an id returned byGtk.Widget.add_tick_callback
()
Removes a tick callback previously registered with
Gtk.Widget.add_tick_callback
().New in version 3.8.
- render_icon(stock_id, size, detail)[source]¶
- Parameters:
stock_id (
str
) – a stock IDsize (
int
) – a stock size (Gtk.IconSize
). A size of(GtkIconSize)-1
means render at the size of the source and don’t scale (if there are multiple source sizes, GTK+ picks one of the available sizes).detail (
str
orNone
) – render detail to pass to theme engine
- Returns:
a new pixbuf, or
None
if the stock ID wasn’t known- Return type:
A convenience function that uses the theme settings for self to look up stock_id and render it to a pixbuf. stock_id should be a stock icon ID such as
Gtk.STOCK_OPEN
orGtk.STOCK_OK
. size should be a size such asGtk.IconSize.MENU
. detail should be a string that identifies the widget or code doing the rendering, so that theme engines can special-case rendering for that widget or code.The pixels in the returned
GdkPixbuf.Pixbuf
are shared with the rest of the application and should not be modified. The pixbuf should be freed after use withGObject.Object.unref
().Deprecated since version 3.0: Use
Gtk.Widget.render_icon_pixbuf
() instead.
- render_icon_pixbuf(stock_id, size)[source]¶
- Parameters:
stock_id (
str
) – a stock IDsize (
int
) – a stock size (Gtk.IconSize
). A size of(GtkIconSize)-1
means render at the size of the source and don’t scale (if there are multiple source sizes, GTK+ picks one of the available sizes).
- Returns:
a new pixbuf, or
None
if the stock ID wasn’t known- Return type:
A convenience function that uses the theme engine and style settings for self to look up stock_id and render it to a pixbuf. stock_id should be a stock icon ID such as
Gtk.STOCK_OPEN
orGtk.STOCK_OK
. size should be a size such asGtk.IconSize.MENU
.The pixels in the returned
GdkPixbuf.Pixbuf
are shared with the rest of the application and should not be modified. The pixbuf should be freed after use withGObject.Object.unref
().New in version 3.0.
Deprecated since version 3.10: Use
Gtk.IconTheme.load_icon
() instead.
- reparent(new_parent)[source]¶
- Parameters:
new_parent (
Gtk.Widget
) – aGtk.Container
to move the widget into
Moves a widget from one
Gtk.Container
to another, handling reference count issues to avoid destroying the widget.Deprecated since version 3.14: Use
Gtk.Container.remove
() andGtk.Container.add
().
- reset_rc_styles()[source]¶
Reset the styles of self and all descendents, so when they are looked up again, they get the correct values for the currently loaded RC file settings.
This function is not useful for applications.
Deprecated since version 3.0: Use
Gtk.StyleContext
instead, andGtk.Widget.reset_style
()
- reset_style()[source]¶
Updates the style context of self and all descendants by updating its widget path.
Gtk.Containers
may want to use this on a child when reordering it in a way that a different style might apply to it. See alsoGtk.Container.get_path_for_child
().New in version 3.0.
- send_expose(event)[source]¶
- Parameters:
- Returns:
return from the event signal emission (
True
if the event was handled)- Return type:
Very rarely-used function. This function is used to emit an expose event on a widget. This function is not normally used directly. The only time it is used is when propagating an expose event to a windowless child widget (
Gtk.Widget.get_has_window
() isFalse
), and that is normally done usingGtk.Container.propagate_draw
().If you want to force an area of a window to be redrawn, use
Gdk.Window.invalidate_rect
() orGdk.Window.invalidate_region
(). To cause the redraw to be done immediately, follow that call with a call toGdk.Window.process_updates
().Deprecated since version 3.22: Application and widget code should not handle expose events directly; invalidation should use the
Gtk.Widget
API, and drawing should only happen insideGtk.Widget
::draw
implementations
- send_focus_change(event)[source]¶
- Parameters:
event (
Gdk.Event
) – aGdk.Event
of typeGdk.EventType.FOCUS_CHANGE
- Returns:
the return value from the event signal emission:
True
if the event was handled, andFalse
otherwise- Return type:
Sends the focus change event to self
This function is not meant to be used by applications. The only time it should be used is when it is necessary for a
Gtk.Widget
to assign focus to a widget that is semantically owned by the first widget even though it’s not a direct child - for instance, a search entry in a floating window similar to the quick search inGtk.TreeView
.An example of its usage is:
GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE); fevent->focus_change.type = GDK_FOCUS_CHANGE; fevent->focus_change.in = TRUE; fevent->focus_change.window = _gtk_widget_get_window (widget); if (fevent->focus_change.window != NULL) g_object_ref (fevent->focus_change.window); gtk_widget_send_focus_change (widget, fevent); gdk_event_free (event);
New in version 2.20.
- set_accel_path(accel_path, accel_group)[source]¶
- Parameters:
accel_path (
str
orNone
) – path used to look up the acceleratoraccel_group (
Gtk.AccelGroup
orNone
) – aGtk.AccelGroup
.
Given an accelerator group, accel_group, and an accelerator path, accel_path, sets up an accelerator in accel_group so whenever the key binding that is defined for accel_path is pressed, self will be activated. This removes any accelerators (for any accelerator group) installed by previous calls to
Gtk.Widget.set_accel_path
(). Associating accelerators with paths allows them to be modified by the user and the modifications to be saved for future use. (SeeGtk.AccelMap.save
().)This function is a low level function that would most likely be used by a menu creation system like
Gtk.UIManager
. If you useGtk.UIManager
, setting up accelerator paths will be done automatically.Even when you you aren’t using
Gtk.UIManager
, if you only want to set up accelerators on menu itemsGtk.MenuItem.set_accel_path
() provides a somewhat more convenient interface.Note that accel_path string will be stored in a #GQuark. Therefore, if you pass a static string, you can save some memory by interning it first with
GLib.intern_static_string
().
- set_allocation(allocation)[source]¶
- Parameters:
allocation (
Gdk.Rectangle
) – a pointer to a #GtkAllocation to copy from
Sets the widget’s allocation. This should not be used directly, but from within a widget’s size_allocate method.
The allocation set should be the “adjusted” or actual allocation. If you’re implementing a
Gtk.Container
, you want to useGtk.Widget.size_allocate
() instead ofGtk.Widget.set_allocation
(). The GtkWidgetClass::adjust_size_allocation virtual method adjusts the allocation insideGtk.Widget.size_allocate
() to create an adjusted allocation.New in version 2.18.
- set_app_paintable(app_paintable)[source]¶
-
Sets whether the application intends to draw on the widget in an
Gtk.Widget
::draw
handler.This is a hint to the widget and does not affect the behavior of the GTK+ core; many widgets ignore this flag entirely. For widgets that do pay attention to the flag, such as
Gtk.EventBox
andGtk.Window
, the effect is to suppress default themed drawing of the widget’s background. (Children of the widget will still be drawn.) The application is then entirely responsible for drawing the widget background.Note that the background is still drawn when the widget is mapped.
- set_can_default(can_default)[source]¶
- Parameters:
can_default (
bool
) – whether or not self can be a default widget.
Specifies whether self can be a default widget. See
Gtk.Widget.grab_default
() for details about the meaning of “default”.New in version 2.18.
- set_can_focus(can_focus)[source]¶
- Parameters:
can_focus (
bool
) – whether or not self can own the input focus.
Specifies whether self can own the input focus. See
Gtk.Widget.grab_focus
() for actually setting the input focus on a widget.New in version 2.18.
- set_child_visible(is_visible)[source]¶
-
Sets whether self should be mapped along with its when its parent is mapped and self has been shown with
Gtk.Widget.show
().The child visibility can be set for widget before it is added to a container with
Gtk.Widget.set_parent
(), to avoid mapping children unnecessary before immediately unmapping them. However it will be reset to its default state ofTrue
when the widget is removed from a container.Note that changing the child visibility of a widget does not queue a resize on the widget. Most of the time, the size of a widget is computed from all visible children, whether or not they are mapped. If this is not the case, the container can queue a resize itself.
This function is only useful for container implementations and never should be called by an application.
- set_clip(clip)[source]¶
- Parameters:
clip (
Gdk.Rectangle
) – a pointer to a #GtkAllocation to copy from
Sets the widget’s clip. This must not be used directly, but from within a widget’s size_allocate method. It must be called after
Gtk.Widget.set_allocation
() (or after chaining up to the parent class), because that function resets the clip.The clip set should be the area that self draws on. If self is a
Gtk.Container
, the area must contain all children’s clips.If this function is not called by self during a
::size-allocate
handler, the clip will be set to self's allocation.New in version 3.14.
- set_composite_name(name)[source]¶
- Parameters:
name (
str
) – the name to set
Sets a widgets composite name. The widget must be a composite child of its parent; see
Gtk.Widget.push_composite_child
().Deprecated since version 3.10: Use
Gtk.WidgetClass.set_template
(), or don’t use this API at all.
- set_device_enabled(device, enabled)[source]¶
- Parameters:
device (
Gdk.Device
) – aGdk.Device
enabled (
bool
) – whether to enable the device
Enables or disables a
Gdk.Device
to interact with self and all its children.It does so by descending through the
Gdk.Window
hierarchy and enabling the same mask that is has for core events (i.e. the one thatGdk.Window.get_events
() returns).New in version 3.0.
- set_device_events(device, events)[source]¶
- Parameters:
device (
Gdk.Device
) – aGdk.Device
events (
Gdk.EventMask
) – event mask
Sets the device event mask (see
Gdk.EventMask
) for a widget. The event mask determines which events a widget will receive from device. Keep in mind that different widgets have different default event masks, and by changing the event mask you may disrupt a widget’s functionality, so be careful. This function must be called while a widget is unrealized. ConsiderGtk.Widget.add_device_events
() for widgets that are already realized, or if you want to preserve the existing event mask. This function can’t be used with windowless widgets (which returnFalse
fromGtk.Widget.get_has_window
()); to get events on those widgets, place them inside aGtk.EventBox
and receive events on the event box.New in version 3.0.
- set_direction(dir)[source]¶
- Parameters:
dir (
Gtk.TextDirection
) – the new direction
Sets the reading direction on a particular widget. This direction controls the primary direction for widgets containing text, and also the direction in which the children of a container are packed. The ability to set the direction is present in order so that correct localization into languages with right-to-left reading directions can be done. Generally, applications will let the default reading direction present, except for containers where the containers are arranged in an order that is explicitly visual rather than logical (such as buttons for text justification).
If the direction is set to
Gtk.TextDirection.NONE
, then the value set byGtk.Widget.set_default_direction
() will be used.
- set_double_buffered(double_buffered)[source]¶
-
Widgets are double buffered by default; you can use this function to turn off the buffering. “Double buffered” simply means that
Gdk.Window.begin_draw_frame
() andGdk.Window.end_draw_frame
() are called automatically around expose events sent to the widget.Gdk.Window.begin_draw_frame
() diverts all drawing to a widget’s window to an offscreen buffer, andGdk.Window.end_draw_frame
() draws the buffer to the screen. The result is that users see the window update in one smooth step, and don’t see individual graphics primitives being rendered.In very simple terms, double buffered widgets don’t flicker, so you would only use this function to turn off double buffering if you had special needs and really knew what you were doing.
Note: if you turn off double-buffering, you have to handle expose events, since even the clearing to the background color or pixmap will not happen automatically (as it is done in
Gdk.Window.begin_draw_frame
()).In 3.10 GTK and GDK have been restructured for translucent drawing. Since then expose events for double-buffered widgets are culled into a single event to the toplevel GDK window. If you now unset double buffering, you will cause a separate rendering pass for every widget. This will likely cause rendering problems - in particular related to stacking - and usually increases rendering times significantly.
Deprecated since version 3.14: This function does not work under non-X11 backends or with non-native windows. It should not be used in newly written code.
- set_events(events)[source]¶
- Parameters:
events (
int
) – event mask
Sets the event mask (see
Gdk.EventMask
) for a widget. The event mask determines which events a widget will receive. Keep in mind that different widgets have different default event masks, and by changing the event mask you may disrupt a widget’s functionality, so be careful. This function must be called while a widget is unrealized. ConsiderGtk.Widget.add_events
() for widgets that are already realized, or if you want to preserve the existing event mask. This function can’t be used with widgets that have no window. (SeeGtk.Widget.get_has_window
()). To get events on those widgets, place them inside aGtk.EventBox
and receive events on the event box.
- set_focus_on_click(focus_on_click)[source]¶
- Parameters:
focus_on_click (
bool
) – whether the widget should grab focus when clicked with the mouse
Sets whether the widget should grab focus when it is clicked with the mouse. Making mouse clicks not grab focus is useful in places like toolbars where you don’t want the keyboard focus removed from the main area of the application.
New in version 3.20.
- set_font_map(font_map)[source]¶
- Parameters:
font_map (
Pango.FontMap
orNone
) – aPango.FontMap
, orNone
to unset any previously set font map
Sets the font map to use for Pango rendering. When not set, the widget will inherit the font map from its parent.
New in version 3.18.
- set_font_options(options)[source]¶
- Parameters:
options (
cairo.FontOptions
orNone
) – acairo.FontOptions
, orNone
to unset any previously set default font options.
Sets the
cairo.FontOptions
used for Pango rendering in this widget. When not set, the default font options for theGdk.Screen
will be used.New in version 3.18.
- set_halign(align)[source]¶
- Parameters:
align (
Gtk.Align
) – the horizontal alignment
Sets the horizontal alignment of self. See the
Gtk.Widget
:halign
property.
- set_has_tooltip(has_tooltip)[source]¶
- Parameters:
has_tooltip (
bool
) – whether or not self has a tooltip.
Sets the has-tooltip property on self to has_tooltip. See
Gtk.Widget
:has-tooltip
for more information.New in version 2.12.
- set_has_window(has_window)[source]¶
- Parameters:
has_window (
bool
) – whether or not self has a window.
Specifies whether self has a
Gdk.Window
of its own. Note that all realized widgets have a non-None
“window” pointer (Gtk.Widget.get_window
() never returns aNone
window when a widget is realized), but for many of them it’s actually theGdk.Window
of one of its parent widgets. Widgets that do not create a %window for themselves inGtk.Widget
::realize
must announce this by calling this function with has_window =False
.This function should only be called by widget implementations, and they should call it in their init() function.
New in version 2.18.
- set_hexpand(expand)[source]¶
- Parameters:
expand (
bool
) – whether to expand
Sets whether the widget would like any available extra horizontal space. When a user resizes a
Gtk.Window
, widgets with expand=:obj:True generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.Call this function to set the expand flag if you would like your widget to become larger horizontally when the window has extra room.
By default, widgets automatically expand if any of their children want to expand. (To see if a widget will automatically expand given its current children and state, call
Gtk.Widget.compute_expand
(). A container can decide how the expandability of children affects the expansion of the container by overriding the compute_expand virtual method onGtk.Widget
.).Setting hexpand explicitly with this function will override the automatic expand behavior.
This function forces the widget to expand or not to expand, regardless of children. The override occurs because
Gtk.Widget.set_hexpand
() sets the hexpand-set property (seeGtk.Widget.set_hexpand_set
()) which causes the widget’s hexpand value to be used, rather than looking at children and widget state.
- set_hexpand_set(set)[source]¶
- Parameters:
set (
bool
) – value for hexpand-set property
Sets whether the hexpand flag (see
Gtk.Widget.get_hexpand
()) will be used.The hexpand-set property will be set automatically when you call
Gtk.Widget.set_hexpand
() to set hexpand, so the most likely reason to use this function would be to unset an explicit expand flag.If hexpand is set, then it overrides any computed expand value based on child widgets. If hexpand is not set, then the expand value depends on whether any children of the widget would like to expand.
There are few reasons to use this function, but it’s here for completeness and consistency.
- set_mapped(mapped)[source]¶
-
Marks the widget as being mapped.
This function should only ever be called in a derived widget’s “map” or “unmap” implementation.
New in version 2.20.
- set_margin_bottom(margin)[source]¶
- Parameters:
margin (
int
) – the bottom margin
Sets the bottom margin of self. See the
Gtk.Widget
:margin-bottom
property.New in version 3.0.
- set_margin_end(margin)[source]¶
- Parameters:
margin (
int
) – the end margin
Sets the end margin of self. See the
Gtk.Widget
:margin-end
property.New in version 3.12.
- set_margin_left(margin)[source]¶
- Parameters:
margin (
int
) – the left margin
Sets the left margin of self. See the
Gtk.Widget
:margin-left
property.New in version 3.0.
Deprecated since version 3.12: Use
Gtk.Widget.set_margin_start
() instead.
- set_margin_right(margin)[source]¶
- Parameters:
margin (
int
) – the right margin
Sets the right margin of self. See the
Gtk.Widget
:margin-right
property.New in version 3.0.
Deprecated since version 3.12: Use
Gtk.Widget.set_margin_end
() instead.
- set_margin_start(margin)[source]¶
- Parameters:
margin (
int
) – the start margin
Sets the start margin of self. See the
Gtk.Widget
:margin-start
property.New in version 3.12.
- set_margin_top(margin)[source]¶
- Parameters:
margin (
int
) – the top margin
Sets the top margin of self. See the
Gtk.Widget
:margin-top
property.New in version 3.0.
- set_name(name)[source]¶
- Parameters:
name (
str
) – name for the widget
Widgets can be named, which allows you to refer to them from a CSS file. You can apply a style to widgets with a particular name in the CSS file. See the documentation for the CSS syntax (on the same page as the docs for
Gtk.StyleContext
).Note that the CSS syntax has certain special characters to delimit and represent elements in a selector (period, #, >, *…), so using these will make your widget impossible to match by name. Any combination of alphanumeric symbols, dashes and underscores will suffice.
- set_no_show_all(no_show_all)[source]¶
- Parameters:
no_show_all (
bool
) – the new value for the “no-show-all” property
Sets the
Gtk.Widget
:no-show-all
property, which determines whether calls toGtk.Widget.show_all
() will affect this widget.This is mostly for use in constructing widget hierarchies with externally controlled visibility, see
Gtk.UIManager
.New in version 2.4.
- set_opacity(opacity)[source]¶
- Parameters:
opacity (
float
) – desired opacity, between 0 and 1
Request the self to be rendered partially transparent, with opacity 0 being fully transparent and 1 fully opaque. (Opacity values are clamped to the [0,1] range.). This works on both toplevel widget, and child widgets, although there are some limitations:
For toplevel widgets this depends on the capabilities of the windowing system. On X11 this has any effect only on X screens with a compositing manager running. See
Gtk.Widget.is_composited
(). On Windows it should work always, although setting a window’s opacity after the window has been shown causes it to flicker once on Windows.For child widgets it doesn’t work if any affected widget has a native window, or disables double buffering.
New in version 3.8.
- set_parent(parent)[source]¶
- Parameters:
parent (
Gtk.Widget
) – parent container
This function is useful only when implementing subclasses of
Gtk.Container
. Sets the container as the parent of self, and takes care of some details such as updating the state and style of the child to reflect its new location. The opposite function isGtk.Widget.unparent
().
- set_parent_window(parent_window)[source]¶
- Parameters:
parent_window (
Gdk.Window
) – the new parent window.
Sets a non default parent window for self.
For
Gtk.Window
classes, setting a parent_window effects whether the window is a toplevel window or can be embedded into other widgets.For
Gtk.Window
classes, this needs to be called before the window is realized.
- set_realized(realized)[source]¶
-
Marks the widget as being realized. This function must only be called after all
Gdk.Windows
for the self have been created and registered.This function should only ever be called in a derived widget’s “realize” or “unrealize” implementation.
New in version 2.20.
- set_receives_default(receives_default)[source]¶
- Parameters:
receives_default (
bool
) – whether or not self can be a default widget.
Specifies whether self will be treated as the default widget within its toplevel when it has the focus, even if another widget is the default.
See
Gtk.Widget.grab_default
() for details about the meaning of “default”.New in version 2.18.
- set_redraw_on_allocate(redraw_on_allocate)[source]¶
- Parameters:
redraw_on_allocate (
bool
) – ifTrue
, the entire widget will be redrawn when it is allocated to a new size. Otherwise, only the new portion of the widget will be redrawn.
Sets whether the entire widget is queued for drawing when its size allocation changes. By default, this setting is
True
and the entire widget is redrawn on every size change. If your widget leaves the upper left unchanged when made bigger, turning this setting off will improve performance.Note that for widgets where
Gtk.Widget.get_has_window
() isFalse
setting this flag toFalse
turns off all allocation on resizing: the widget will not even redraw if its position changes; this is to allow containers that don’t draw anything to avoid excess invalidations. If you set this flag on a widget with no window that does draw on self->window, you are responsible for invalidating both the old and new allocation of the widget when the widget is moved and responsible for invalidating regions newly when the widget increases size.
- set_sensitive(sensitive)[source]¶
-
Sets the sensitivity of a widget. A widget is sensitive if the user can interact with it. Insensitive widgets are “grayed out” and the user can’t interact with them. Insensitive widgets are known as “inactive”, “disabled”, or “ghosted” in some other toolkits.
- set_size_request(width, height)[source]¶
- Parameters:
Sets the minimum size of a widget; that is, the widget’s size request will be at least width by height. You can use this function to force a widget to be larger than it normally would be.
In most cases,
Gtk.Window.set_default_size
() is a better choice for toplevel windows than this function; setting the default size will still allow users to shrink the window. Setting the size request will force them to leave the window at least as large as the size request. When dealing with window sizes,Gtk.Window.set_geometry_hints
() can be a useful function as well.Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can all change the appropriate size for a given widget. So, it’s basically impossible to hardcode a size that will always be correct.
The size request of a widget is the smallest size a widget can accept while still functioning well and drawing itself correctly. However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it requested.
If the size request in a given direction is -1 (unset), then the “natural” size request of the widget will be used instead.
The size request set here does not include any margin from the
Gtk.Widget
properties margin-left, margin-right, margin-top, and margin-bottom, but it does include pretty much all other padding or border properties set by any subclass ofGtk.Widget
.
- set_state(state)[source]¶
- Parameters:
state (
Gtk.StateType
) – new state for self
This function is for use in widget implementations. Sets the state of a widget (insensitive, prelighted, etc.) Usually you should set the state using wrapper functions such as
Gtk.Widget.set_sensitive
().Deprecated since version 3.0: Use
Gtk.Widget.set_state_flags
() instead.
- set_state_flags(flags, clear)[source]¶
- Parameters:
flags (
Gtk.StateFlags
) – State flags to turn onclear (
bool
) – Whether to clear state before turning on flags
This function is for use in widget implementations. Turns on flag values in the current widget state (insensitive, prelighted, etc.).
This function accepts the values
Gtk.StateFlags.DIR_LTR
andGtk.StateFlags.DIR_RTL
but ignores them. If you want to set the widget’s direction, useGtk.Widget.set_direction
().It is worth mentioning that any other state than
Gtk.StateFlags.INSENSITIVE
, will be propagated down to all non-internal children if self is aGtk.Container
, whileGtk.StateFlags.INSENSITIVE
itself will be propagated down to allGtk.Container
children by different means than turning on the state flag down the hierarchy, bothGtk.Widget.get_state_flags
() andGtk.Widget.is_sensitive
() will make use of these.New in version 3.0.
- set_style(style)[source]¶
- Parameters:
style (
Gtk.Style
orNone
) – aGtk.Style
, orNone
to remove the effect of a previous call toGtk.Widget.set_style
() and go back to the default style
Used to set the
Gtk.Style
for a widget (self->style). Since GTK 3, this function does nothing, the passed in style is ignored.Deprecated since version 3.0: Use
Gtk.StyleContext
instead
- set_support_multidevice(support_multidevice)[source]¶
-
Enables or disables multiple pointer awareness. If this setting is
True
, self will start receiving multiple, per device enter/leave events. Note that if customGdk.Windows
are created inGtk.Widget
::realize
,Gdk.Window.set_support_multidevice
() will have to be called manually on them.New in version 3.0.
- set_tooltip_markup(markup)[source]¶
-
Sets markup as the contents of the tooltip, which is marked up with the Pango text markup language.
This function will take care of setting
Gtk.Widget
:has-tooltip
toTrue
and of the default handler for theGtk.Widget
::query-tooltip
signal.See also the
Gtk.Widget
:tooltip-markup
property andGtk.Tooltip.set_markup
().New in version 2.12.
- set_tooltip_text(text)[source]¶
-
Sets text as the contents of the tooltip. This function will take care of setting
Gtk.Widget
:has-tooltip
toTrue
and of the default handler for theGtk.Widget
::query-tooltip
signal.See also the
Gtk.Widget
:tooltip-text
property andGtk.Tooltip.set_text
().New in version 2.12.
- set_tooltip_window(custom_window)[source]¶
- Parameters:
custom_window (
Gtk.Window
orNone
) – aGtk.Window
, orNone
Replaces the default window used for displaying tooltips with custom_window. GTK+ will take care of showing and hiding custom_window at the right moment, to behave likewise as the default tooltip window. If custom_window is
None
, the default tooltip window will be used.New in version 2.12.
- set_valign(align)[source]¶
- Parameters:
align (
Gtk.Align
) – the vertical alignment
Sets the vertical alignment of self. See the
Gtk.Widget
:valign
property.
- set_vexpand(expand)[source]¶
- Parameters:
expand (
bool
) – whether to expand
Sets whether the widget would like any available extra vertical space.
See
Gtk.Widget.set_hexpand
() for more detail.
- set_vexpand_set(set)[source]¶
- Parameters:
set (
bool
) – value for vexpand-set property
Sets whether the vexpand flag (see
Gtk.Widget.get_vexpand
()) will be used.See
Gtk.Widget.set_hexpand_set
() for more detail.
- set_visible(visible)[source]¶
- Parameters:
visible (
bool
) – whether the widget should be shown or not
Sets the visibility state of self. Note that setting this to
True
doesn’t mean the widget is actually viewable, seeGtk.Widget.get_visible
().This function simply calls
Gtk.Widget.show
() orGtk.Widget.hide
() but is nicer to use when the visibility of the widget depends on some condition.New in version 2.18.
- set_visual(visual)[source]¶
- Parameters:
visual (
Gdk.Visual
orNone
) – visual to be used orNone
to unset a previous one
Sets the visual that should be used for by widget and its children for creating
Gdk.Windows
. The visual must be on the sameGdk.Screen
as returned byGtk.Widget.get_screen
(), so handling theGtk.Widget
::screen-changed
signal is necessary.Setting a new visual will not cause self to recreate its windows, so you should call this function before self is realized.
- set_window(window)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
Sets a widget’s window. This function should only be used in a widget’s
Gtk.Widget
::realize
implementation. The %window passed is usually either new window created withGdk.Window.new
(), or the window of its parent widget as returned byGtk.Widget.get_parent_window
().Widgets must indicate whether they will create their own
Gdk.Window
by callingGtk.Widget.set_has_window
(). This is usually done in the widget’s init() function.Note that this function does not add any reference to window.
New in version 2.18.
- shape_combine_region(region)[source]¶
- Parameters:
region (
cairo.Region
orNone
) – shape to be added, orNone
to remove an existing shape
Sets a shape for this widget’s GDK window. This allows for transparent windows etc., see
Gdk.Window.shape_combine_region
() for more information.New in version 3.0.
- show()[source]¶
Flags a widget to be displayed. Any widget that isn’t shown will not appear on the screen. If you want to show all the widgets in a container, it’s easier to call
Gtk.Widget.show_all
() on the container, instead of individually showing the widgets.Remember that you have to show the containers containing a widget, in addition to the widget itself, before it will appear onscreen.
When a toplevel container is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel container is realized and mapped.
- show_all()[source]¶
Recursively shows a widget, and any child widgets (if the widget is a container).
- show_now()[source]¶
Shows a widget. If the widget is an unmapped toplevel widget (i.e. a
Gtk.Window
that has not yet been shown), enter the main loop and wait for the window to actually be mapped. Be careful; because the main loop is running, anything can happen during this function.
- size_allocate(allocation)[source]¶
- Parameters:
allocation (
Gdk.Rectangle
) – position and size to be allocated to self
This function is only used by
Gtk.Container
subclasses, to assign a size and position to their child widgets.In this function, the allocation may be adjusted. It will be forced to a 1x1 minimum size, and the adjust_size_allocation virtual method on the child will be used to adjust the allocation. Standard adjustments include removing the widget’s margins, and applying the widget’s
Gtk.Widget
:halign
andGtk.Widget
:valign
properties.For baseline support in containers you need to use
Gtk.Widget.size_allocate_with_baseline
() instead.
- size_allocate_with_baseline(allocation, baseline)[source]¶
- Parameters:
allocation (
Gdk.Rectangle
) – position and size to be allocated to selfbaseline (
int
) – The baseline of the child, or -1
This function is only used by
Gtk.Container
subclasses, to assign a size, position and (optionally) baseline to their child widgets.In this function, the allocation and baseline may be adjusted. It will be forced to a 1x1 minimum size, and the adjust_size_allocation virtual and adjust_baseline_allocation methods on the child will be used to adjust the allocation and baseline. Standard adjustments include removing the widget’s margins, and applying the widget’s
Gtk.Widget
:halign
andGtk.Widget
:valign
properties.If the child widget does not have a valign of
Gtk.Align.BASELINE
the baseline argument is ignored and -1 is used instead.New in version 3.10.
- size_request()[source]¶
- Returns:
a
Gtk.Requisition
to be filled in- Return type:
requisition:
Gtk.Requisition
This function is typically used when implementing a
Gtk.Container
subclass. Obtains the preferred size of a widget. The container uses this information to arrange its child widgets and decide what size allocations to give them withGtk.Widget.size_allocate
().You can also call this function from an application, with some caveats. Most notably, getting a size request requires the widget to be associated with a screen, because font information may be needed. Multihead-aware applications should keep this in mind.
Also remember that the size request is not necessarily the size a widget will actually be allocated.
Deprecated since version 3.0: Use
Gtk.Widget.get_preferred_size
() instead.
- style_attach()[source]¶
This function attaches the widget’s
Gtk.Style
to the widget’sGdk.Window
. It is a replacement forwidget->style = gtk_style_attach (widget->style, widget->window);
and should only ever be called in a derived widget’s “realize” implementation which does not chain up to its parent class’ “realize” implementation, because one of the parent classes (finally
Gtk.Widget
) would attach the style itself.New in version 2.20.
Deprecated since version 3.0: This step is unnecessary with
Gtk.StyleContext
.
- style_get_property(property_name, value=None)[source]¶
- Parameters:
property_name (
str
) – the name of a style propertyvalue (
GObject.Value
orNone
) – EitherNone
or a correctly initializedGObject.Value
- Returns:
The Python value of the style property
Gets the value of a style property of self.
- thaw_child_notify()[source]¶
Reverts the effect of a previous call to
Gtk.Widget.freeze_child_notify
(). This causes all queuedGtk.Widget
::child-notify
signals on self to be emitted.
- translate_coordinates(dest_widget, src_x, src_y)[source]¶
- Parameters:
dest_widget (
Gtk.Widget
) – aGtk.Widget
src_x (
int
) – X position relative to selfsrc_y (
int
) – Y position relative to self
- Returns:
None
if either widget was not realized, or there was no common ancestor. Otherwise a(dest_x, dest_y)
tuple containing the X and Y position relative to dest_widget.- Return type:
Translate coordinates relative to self’s allocation to coordinates relative to dest_widget’s allocations. In order to perform this operation, both widgets must be realized, and must share a common toplevel.
- trigger_tooltip_query()[source]¶
Triggers a tooltip query on the display where the toplevel of self is located. See
Gtk.Tooltip.trigger_tooltip_query
() for more information.New in version 2.12.
- unmap()[source]¶
This function is only for use in widget implementations. Causes a widget to be unmapped if it’s currently mapped.
- unparent()[source]¶
This function is only for use in widget implementations. Should be called by implementations of the remove method on
Gtk.Container
, to dissociate a child from the container.
- unrealize()[source]¶
This function is only useful in widget implementations. Causes a widget to be unrealized (frees all GDK resources associated with the widget, such as self->window).
- unregister_window(window)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
Unregisters a
Gdk.Window
from the widget that was previously set up withGtk.Widget.register_window
(). You need to call this when the window is no longer used by the widget, such as when you destroy it.New in version 3.8.
- unset_state_flags(flags)[source]¶
- Parameters:
flags (
Gtk.StateFlags
) – State flags to turn off
This function is for use in widget implementations. Turns off flag values for the current widget state (insensitive, prelighted, etc.). See
Gtk.Widget.set_state_flags
().New in version 3.0.
- do_adjust_baseline_request(minimum_baseline, natural_baseline) virtual¶
- do_adjust_size_allocation(orientation, minimum_size, natural_size, allocated_pos, allocated_size) virtual¶
- Parameters:
orientation (
Gtk.Orientation
) –minimum_size (
int
) –natural_size (
int
) –allocated_pos (
int
) –allocated_size (
int
) –
Convert an initial size allocation assigned by a
Gtk.Container
usingGtk.Widget.size_allocate
(), into an actual size allocation to be used by the widget. adjust_size_allocation adjusts to a child widget’s actual allocation from what a parent container computed for the child. The adjusted allocation must be entirely within the original allocation. In any custom implementation, chain up to the defaultGtk.Widget
implementation of this method, which applies the margin and alignment properties ofGtk.Widget
. Chain up before performing your own adjustments so your own adjustments remove more allocation after theGtk.Widget
base class has already removed margin and alignment. The natural size passed in should be adjusted in the same way as the allocated size, which allows adjustments to perform alignments or other changes based on natural size.
- do_adjust_size_request(orientation, minimum_size, natural_size) virtual¶
- Parameters:
orientation (
Gtk.Orientation
) –minimum_size (
int
) –natural_size (
int
) –
Convert an initial size request from a widget’s
Gtk.SizeRequestMode
virtual method implementations into a size request to be used by parent containers in laying out the widget. adjust_size_request adjusts from a child widget’s original request to what a parent container should use for layout. The for_size argument will be -1 if the request should not be for a particular size in the opposing orientation, i.e. if the request is not height-for-width or width-for-height. If for_size is greater than -1, it is the proposed allocation in the opposing orientation that we need the request for. Implementations of adjust_size_request should chain up to the default implementation, which appliesGtk.Widget
’s margin properties and imposes any values fromGtk.Widget.set_size_request
(). Chaining up should be last, after your subclass adjusts the request, soGtk.Widget
can apply constraints and add the margin properly.
- do_button_press_event(event) virtual¶
- Parameters:
event (
Gdk.EventButton
) –- Return type:
Signal will be emitted when a button (typically from a mouse) is pressed.
- do_button_release_event(event) virtual¶
- Parameters:
event (
Gdk.EventButton
) –- Return type:
Signal will be emitted when a button (typically from a mouse) is released.
- do_can_activate_accel(signal_id) virtual¶
- Parameters:
signal_id (
int
) – the ID of a signal installed on widget- Returns:
True
if the accelerator can be activated.- Return type:
Determines whether an accelerator that activates the signal identified by signal_id can currently be activated. This is done by emitting the
Gtk.Widget
::can-activate-accel
signal on widget; if the signal isn’t overridden by a handler or in a derived widget, then the default check is that the widget must be sensitive, and the widget and all its ancestors mapped.New in version 2.4.
- do_child_notify(child_property) virtual¶
- Parameters:
child_property (
GObject.ParamSpec
) – the name of a child property installed on the class of widget’s parent
Emits a
Gtk.Widget
::child-notify
signal for the ‘child property [child-properties]’ child_property on widget.This is the analogue of
GObject.Object.notify
() for child properties.Also see
Gtk.Container.child_notify
().
- do_composited_changed() virtual¶
Signal emitted when the composited status of widgets screen changes. See
Gdk.Screen.is_composited
().
- do_compute_expand(hexpand_p, vexpand_p) virtual¶
-
Computes whether a container should give this widget extra space when possible.
- do_configure_event(event) virtual¶
- Parameters:
event (
Gdk.EventConfigure
) –- Return type:
Signal will be emitted when the size, position or stacking of the widget’s window has changed.
- do_damage_event(event) virtual¶
- Parameters:
event (
Gdk.EventExpose
) –- Return type:
Signal emitted when a redirected window belonging to widget gets drawn into.
- do_delete_event(event) virtual¶
- Parameters:
event (
Gdk.EventAny
) –- Return type:
Signal emitted if a user requests that a toplevel window is closed.
- do_destroy() virtual¶
Destroys a widget.
When a widget is destroyed all references it holds on other objects will be released:
if the widget is inside a container, it will be removed from its parent
if the widget is a container, all its children will be destroyed, recursively
if the widget is a top level, it will be removed from the list of top level widgets that GTK+ maintains internally
It’s expected that all references held on the widget will also be released; you should connect to the
Gtk.Widget
::destroy
signal if you hold a reference to widget and you wish to remove it when this function is called. It is not necessary to do so if you are implementing aGtk.Container
, as you’ll be able to use theGtk.Container.do_remove
() virtual function for that.It’s important to notice that
Gtk.Widget.destroy
() will only cause the widget to be finalized if no additional references, acquired usingGObject.Object.ref
(), are held on it. In case additional references are in place, the widget will be in an “inert” state after calling this function; widget will still point to valid memory, allowing you to release the references you hold, but you may not query the widget’s own state.You should typically call this function on top level widgets, and rarely on child widgets.
See also:
Gtk.Container.remove
()
- do_destroy_event(event) virtual¶
- Parameters:
event (
Gdk.EventAny
) –- Return type:
Signal is emitted when a
Gdk.Window
is destroyed.
- do_direction_changed(previous_direction) virtual¶
- Parameters:
previous_direction (
Gtk.TextDirection
) –
Signal emitted when the text direction of a widget changes.
- do_dispatch_child_properties_changed(n_pspecs, pspecs) virtual¶
- Parameters:
n_pspecs (
int
) –pspecs (
GObject.ParamSpec
) –
Seldomly overidden.
- do_drag_begin(context) virtual¶
- Parameters:
context (
Gdk.DragContext
) –
Signal emitted on the drag source when a drag is started.
- do_drag_data_delete(context) virtual¶
- Parameters:
context (
Gdk.DragContext
) –
Signal emitted on the drag source when a drag with the action
Gdk.DragAction.MOVE
is successfully completed.
- do_drag_data_get(context, selection_data, info, time_) virtual¶
- Parameters:
context (
Gdk.DragContext
) –selection_data (
Gtk.SelectionData
) –info (
int
) –time (
int
) –
Signal emitted on the drag source when the drop site requests the data which is dragged.
- do_drag_data_received(context, x, y, selection_data, info, time_) virtual¶
- Parameters:
context (
Gdk.DragContext
) –x (
int
) –y (
int
) –selection_data (
Gtk.SelectionData
) –info (
int
) –time (
int
) –
Signal emitted on the drop site when the dragged data has been received.
- do_drag_drop(context, x, y, time_) virtual¶
- Parameters:
context (
Gdk.DragContext
) –x (
int
) –y (
int
) –time (
int
) –
- Return type:
Signal emitted on the drop site when the user drops the data onto the widget.
- do_drag_end(context) virtual¶
- Parameters:
context (
Gdk.DragContext
) –
Signal emitted on the drag source when a drag is finished.
- do_drag_failed(context, result) virtual¶
- Parameters:
context (
Gdk.DragContext
) –result (
Gtk.DragResult
) –
- Return type:
Signal emitted on the drag source when a drag has failed.
- do_drag_leave(context, time_) virtual¶
- Parameters:
context (
Gdk.DragContext
) –time (
int
) –
Signal emitted on the drop site when the cursor leaves the widget.
- do_drag_motion(context, x, y, time_) virtual¶
- Parameters:
context (
Gdk.DragContext
) –x (
int
) –y (
int
) –time (
int
) –
- Return type:
signal emitted on the drop site when the user moves the cursor over the widget during a drag.
- do_draw(cr) virtual¶
- Parameters:
cr (
cairo.Context
) –- Return type:
Signal emitted when a widget is supposed to render itself.
- do_enter_notify_event(event) virtual¶
- Parameters:
event (
Gdk.EventCrossing
) –- Return type:
Signal event will be emitted when the pointer enters the widget’s window.
- do_event(event) virtual¶
- Parameters:
- Returns:
return from the event signal emission (
True
if the event was handled)- Return type:
Rarely-used function. This function is used to emit the event signals on a widget (those signals should never be emitted without using this function to do so). If you want to synthesize an event though, don’t use this function; instead, use
Gtk.main_do_event
() so the event will behave as if it were in the event queue. Don’t synthesize expose events; instead, useGdk.Window.invalidate_rect
() to invalidate a region of the window.
- do_focus(direction) virtual¶
- Parameters:
direction (
Gtk.DirectionType
) –- Return type:
- do_focus_in_event(event) virtual¶
- Parameters:
event (
Gdk.EventFocus
) –- Return type:
Signal emitted when the keyboard focus enters the widget’s window.
- do_focus_out_event(event) virtual¶
- Parameters:
event (
Gdk.EventFocus
) –- Return type:
Signal emitted when the keyboard focus leaves the widget’s window.
- do_get_accessible() virtual¶
- Returns:
the
Atk.Object
associated with widget- Return type:
Returns the accessible object that describes the widget to an assistive technology.
If accessibility support is not available, this
Atk.Object
instance may be a no-op. Likewise, if no class-specificAtk.Object
implementation is available for the widget instance in question, it will inherit anAtk.Object
implementation from the first ancestor class for which such an implementation is defined.The documentation of the ATK library contains more information about accessible objects and their uses.
- do_get_preferred_height() virtual¶
- Returns:
- Return type:
Retrieves a widget’s initial minimum and natural height.
This call is specific to width-for-height requests.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any
Gtk.SizeGroups
that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.New in version 3.0.
- do_get_preferred_height_and_baseline_for_width(width) virtual¶
- Parameters:
width (
int
) – the width which is available for allocation, or -1 if none- Returns:
- Return type:
(minimum_height:
int
, natural_height:int
, minimum_baseline:int
, natural_baseline:int
)
Retrieves a widget’s minimum and natural height and the corresponding baselines if it would be given the specified width, or the default height if width is -1. The baselines may be -1 which means that no baseline is requested for this widget.
The returned request will be modified by the GtkWidgetClass::adjust_size_request and GtkWidgetClass::adjust_baseline_request virtual methods and by any
Gtk.SizeGroups
that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.New in version 3.10.
- do_get_preferred_height_for_width(width) virtual¶
- Parameters:
width (
int
) – the width which is available for allocation- Returns:
- Return type:
Retrieves a widget’s minimum and natural height if it would be given the specified width.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any
Gtk.SizeGroups
that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.New in version 3.0.
- do_get_preferred_width() virtual¶
- Returns:
- Return type:
Retrieves a widget’s initial minimum and natural width.
This call is specific to height-for-width requests.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any
Gtk.SizeGroups
that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.New in version 3.0.
- do_get_preferred_width_for_height(height) virtual¶
- Parameters:
height (
int
) – the height which is available for allocation- Returns:
- Return type:
Retrieves a widget’s minimum and natural width if it would be given the specified height.
The returned request will be modified by the GtkWidgetClass::adjust_size_request virtual method and by any
Gtk.SizeGroups
that have been applied. That is, the returned request is the one that should be used for layout, not necessarily the one returned by the widget itself.New in version 3.0.
- do_get_request_mode() virtual¶
- Returns:
The
Gtk.SizeRequestMode
preferred by widget.- Return type:
Gets whether the widget prefers a height-for-width layout or a width-for-height layout.
Gtk.Bin
widgets generally propagate the preference of their child, container widgets need to request something either in context of their children or in context of their allocation capabilities.New in version 3.0.
- do_grab_broken_event(event) virtual¶
- Parameters:
event (
Gdk.EventGrabBroken
) –- Return type:
Signal emitted when a pointer or keyboard grab on a window belonging to widget gets broken.
- do_grab_focus() virtual¶
Causes widget to have the keyboard focus for the
Gtk.Window
it’s inside. widget must be a focusable widget, such as aGtk.Entry
; something likeGtk.Frame
won’t work.More precisely, it must have the %GTK_CAN_FOCUS flag set. Use
Gtk.Widget.set_can_focus
() to modify that flag.The widget also needs to be realized and mapped. This is indicated by the related signals. Grabbing the focus immediately after creating the widget will likely fail and cause critical warnings.
- do_grab_notify(was_grabbed) virtual¶
- Parameters:
was_grabbed (
bool
) –
Signal emitted when a widget becomes shadowed by a GTK+ grab (not a pointer or keyboard grab) on another widget, or when it becomes unshadowed due to a grab being removed.
- do_hide() virtual¶
Reverses the effects of
Gtk.Widget.show
(), causing the widget to be hidden (invisible to the user).
- do_hierarchy_changed(previous_toplevel) virtual¶
- Parameters:
previous_toplevel (
Gtk.Widget
) –
Signal emitted when the anchored state of a widget changes.
- do_key_press_event(event) virtual¶
- Parameters:
event (
Gdk.EventKey
) –- Return type:
Signal emitted when a key is pressed.
- do_key_release_event(event) virtual¶
- Parameters:
event (
Gdk.EventKey
) –- Return type:
Signal is emitted when a key is released.
- Parameters:
direction (
Gtk.DirectionType
) – direction of focus movement- Returns:
True
if stopping keyboard navigation is fine,False
if the emitting widget should try to handle the keyboard navigation attempt in its parent container(s).- Return type:
This function should be called whenever keyboard navigation within a single widget hits a boundary. The function emits the
Gtk.Widget
::keynav-failed
signal on the widget and its return value should be interpreted in a way similar to the return value ofGtk.Widget.child_focus
():When
True
is returned, stay in the widget, the failed keyboard navigation is OK and/or there is nowhere we can/should move the focus to.When
False
is returned, the caller should continue with keyboard navigation outside the widget, e.g. by callingGtk.Widget.child_focus
() on the widget’s toplevel.The default
::keynav-failed
handler returnsFalse
forGtk.DirectionType.TAB_FORWARD
andGtk.DirectionType.TAB_BACKWARD
. For the other values ofGtk.DirectionType
it returnsTrue
.Whenever the default handler returns
True
, it also callsGtk.Widget.error_bell
() to notify the user of the failed keyboard navigation.A use case for providing an own implementation of
::keynav-failed
(either by connecting to it or by overriding it) would be a row ofGtk.Entry
widgets where the user should be able to navigate the entire row with the cursor keys, as e.g. known from user interfaces that require entering license keys.New in version 2.12.
- do_leave_notify_event(event) virtual¶
- Parameters:
event (
Gdk.EventCrossing
) –- Return type:
Will be emitted when the pointer leaves the widget’s window.
- do_map() virtual¶
This function is only for use in widget implementations. Causes a widget to be mapped if it isn’t already.
- do_map_event(event) virtual¶
- Parameters:
event (
Gdk.EventAny
) –- Return type:
Signal emitted when the widget’s window is mapped.
- do_mnemonic_activate(group_cycling) virtual¶
- Parameters:
group_cycling (
bool
) –True
if there are other widgets with the same mnemonic- Returns:
True
if the signal has been handled- Return type:
Emits the
Gtk.Widget
::mnemonic-activate
signal.
- do_motion_notify_event(event) virtual¶
- Parameters:
event (
Gdk.EventMotion
) –- Return type:
Signal emitted when the pointer moves over the widget’s
Gdk.Window
.
- do_move_focus(direction) virtual¶
- Parameters:
direction (
Gtk.DirectionType
) –
Signal emitted when a change of focus is requested
- do_parent_set(previous_parent) virtual¶
- Parameters:
previous_parent (
Gtk.Widget
) –
Signal emitted when a new parent has been set on a widget.
- Return type:
Signal emitted whenever a widget should pop up a context menu.
- do_property_notify_event(event) virtual¶
- Parameters:
event (
Gdk.EventProperty
) –- Return type:
Signal will be emitted when a property on the widget’s window has been changed or deleted.
- do_proximity_in_event(event) virtual¶
- Parameters:
event (
Gdk.EventProximity
) –- Return type:
- do_proximity_out_event(event) virtual¶
- Parameters:
event (
Gdk.EventProximity
) –- Return type:
- do_query_tooltip(x, y, keyboard_tooltip, tooltip) virtual¶
- Parameters:
x (
int
) –y (
int
) –keyboard_tooltip (
bool
) –tooltip (
Gtk.Tooltip
) –
- Return type:
Signal emitted when “has-tooltip” is
True
and the hover timeout has expired with the cursor hovering “above” widget; or emitted when widget got focus in keyboard mode.
- do_queue_draw_region(region) virtual¶
- Parameters:
region (
cairo.Region
) – region to draw
Invalidates the area of widget defined by region by calling
Gdk.Window.invalidate_region
() on the widget’s window and all its child windows. Once the main loop becomes idle (after the current batch of events has been processed, roughly), the window will receive expose events for the union of all regions that have been invalidated.Normally you would only use this function in widget implementations. You might also use it to schedule a redraw of a
Gtk.DrawingArea
or some portion thereof.New in version 3.0.
- do_realize() virtual¶
Creates the GDK (windowing system) resources associated with a widget. For example, widget->window will be created when a widget is realized. Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and mapped automatically.
Realizing a widget requires all the widget’s parent widgets to be realized; calling
Gtk.Widget.realize
() realizes the widget’s parents in addition to widget itself. If a widget is not yet inside a toplevel window when you realize it, bad things will happen.This function is primarily used in widget implementations, and isn’t very useful otherwise. Many times when you think you might need it, a better approach is to connect to a signal that will be called after the widget is realized automatically, such as
Gtk.Widget
::draw
. Or simply g_signal_connect () to theGtk.Widget
::realize
signal.
- do_screen_changed(previous_screen) virtual¶
- Parameters:
previous_screen (
Gdk.Screen
) –
Signal emitted when the screen of a widget has changed.
- do_scroll_event(event) virtual¶
- Parameters:
event (
Gdk.EventScroll
) –- Return type:
Signal emitted when a button in the 4 to 7 range is pressed.
- do_selection_clear_event(event) virtual¶
- Parameters:
event (
Gdk.EventSelection
) –- Return type:
Signal will be emitted when the the widget’s window has lost ownership of a selection.
- do_selection_get(selection_data, info, time_) virtual¶
- Parameters:
selection_data (
Gtk.SelectionData
) –info (
int
) –time (
int
) –
- do_selection_notify_event(event) virtual¶
- Parameters:
event (
Gdk.EventSelection
) –- Return type:
- do_selection_received(selection_data, time_) virtual¶
- Parameters:
selection_data (
Gtk.SelectionData
) –time (
int
) –
- do_selection_request_event(event) virtual¶
- Parameters:
event (
Gdk.EventSelection
) –- Return type:
Signal will be emitted when another client requests ownership of the selection owned by the widget’s window.
- do_show() virtual¶
Flags a widget to be displayed. Any widget that isn’t shown will not appear on the screen. If you want to show all the widgets in a container, it’s easier to call
Gtk.Widget.show_all
() on the container, instead of individually showing the widgets.Remember that you have to show the containers containing a widget, in addition to the widget itself, before it will appear onscreen.
When a toplevel container is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel container is realized and mapped.
- do_show_all() virtual¶
Recursively shows a widget, and any child widgets (if the widget is a container).
- do_show_help(help_type) virtual¶
- Parameters:
help_type (
Gtk.WidgetHelpType
) –- Return type:
- do_size_allocate(allocation) virtual¶
- Parameters:
allocation (
Gdk.Rectangle
) – position and size to be allocated to widget
This function is only used by
Gtk.Container
subclasses, to assign a size and position to their child widgets.In this function, the allocation may be adjusted. It will be forced to a 1x1 minimum size, and the adjust_size_allocation virtual method on the child will be used to adjust the allocation. Standard adjustments include removing the widget’s margins, and applying the widget’s
Gtk.Widget
:halign
andGtk.Widget
:valign
properties.For baseline support in containers you need to use
Gtk.Widget.size_allocate_with_baseline
() instead.
- do_state_changed(previous_state) virtual¶
- Parameters:
previous_state (
Gtk.StateType
) –
Signal emitted when the widget state changes. Deprecated: 3.0
- do_state_flags_changed(previous_state_flags) virtual¶
- Parameters:
previous_state_flags (
Gtk.StateFlags
) –
Signal emitted when the widget state changes, see
Gtk.Widget.get_state_flags
().
- do_style_set(previous_style) virtual¶
- Parameters:
previous_style (
Gtk.Style
) –
Signal emitted when a new style has been set on a widget. Deprecated: 3.0
- do_style_updated() virtual¶
Signal emitted when the
Gtk.StyleContext
of a widget is changed.
- do_touch_event(event) virtual¶
- Parameters:
event (
Gdk.EventTouch
) –- Return type:
Signal emitted when a touch event happens
- do_unmap() virtual¶
This function is only for use in widget implementations. Causes a widget to be unmapped if it’s currently mapped.
- do_unmap_event(event) virtual¶
- Parameters:
event (
Gdk.EventAny
) –- Return type:
Signal will be emitted when the widget’s window is unmapped.
- do_unrealize() virtual¶
This function is only useful in widget implementations. Causes a widget to be unrealized (frees all GDK resources associated with the widget, such as widget->window).
- do_visibility_notify_event(event) virtual¶
- Parameters:
event (
Gdk.EventVisibility
) –- Return type:
Signal emitted when the widget’s window is obscured or unobscured.
- do_window_state_event(event) virtual¶
- Parameters:
event (
Gdk.EventWindowState
) –- Return type:
Signal emitted when the state of the toplevel window associated to the widget changes.
Signal Details¶
- Gtk.Widget.signals.accel_closures_changed(widget)¶
- Signal Name:
accel-closures-changed
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
- Gtk.Widget.signals.button_press_event(widget, event)¶
- Signal Name:
button-press-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventButton
) – theGdk.EventButton
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::button-press-event
signal will be emitted when a button (typically from a mouse) is pressed.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.BUTTON_PRESS_MASK
mask.This signal will be sent to the grab widget if there is one.
- Gtk.Widget.signals.button_release_event(widget, event)¶
- Signal Name:
button-release-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventButton
) – theGdk.EventButton
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::button-release-event
signal will be emitted when a button (typically from a mouse) is released.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.BUTTON_RELEASE_MASK
mask.This signal will be sent to the grab widget if there is one.
- Gtk.Widget.signals.can_activate_accel(widget, signal_id)¶
- Signal Name:
can-activate-accel
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalsignal_id (
int
) – the ID of a signal installed on self
- Returns:
True
if the signal can be activated.- Return type:
Determines whether an accelerator that activates the signal identified by signal_id can currently be activated. This signal is present to allow applications and derived widgets to override the default
Gtk.Widget
handling for determining whether an accelerator can be activated.
- Gtk.Widget.signals.child_notify(widget, child_property)¶
- Signal Name:
child-notify
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalchild_property (
GObject.ParamSpec
) – theGObject.ParamSpec
of the changed child property
The
::child-notify
signal is emitted for each ‘child property [child-properties]’ that has changed on an object. The signal’s detail holds the property name.
- Gtk.Widget.signals.composited_changed(widget)¶
- Signal Name:
composited-changed
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
The
::composited-changed
signal is emitted when the composited status of widgets screen changes. SeeGdk.Screen.is_composited
().Deprecated since version 3.22: Use
Gdk.Screen
::composited-changed
instead.
- Gtk.Widget.signals.configure_event(widget, event)¶
- Signal Name:
configure-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventConfigure
) – theGdk.EventConfigure
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::configure-event
signal will be emitted when the size, position or stacking of the widget's window has changed.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.STRUCTURE_MASK
mask. GDK will enable this mask automatically for all new windows.
- Gtk.Widget.signals.damage_event(widget, event)¶
- Signal Name:
damage-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventExpose
) – theGdk.EventExpose
event
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
Emitted when a redirected window belonging to widget gets drawn into. The region/area members of the event shows what area of the redirected drawable was drawn into.
New in version 2.14.
- Gtk.Widget.signals.delete_event(widget, event)¶
- Signal Name:
delete-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.Event
) – the event which triggered this signal
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::delete-event
signal is emitted if a user requests that a toplevel window is closed. The default handler for this signal destroys the window. ConnectingGtk.Widget.hide_on_delete
() to this signal will cause the window to be hidden instead, so that it can later be shown again without reconstructing it.
- Gtk.Widget.signals.destroy(widget)¶
- Signal Name:
destroy
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
Signals that all holders of a reference to the widget should release the reference that they hold. May result in finalization of the widget if all references are released.
This signal is not suitable for saving widget state.
- Gtk.Widget.signals.destroy_event(widget, event)¶
- Signal Name:
destroy-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.Event
) – the event which triggered this signal
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::destroy-event
signal is emitted when aGdk.Window
is destroyed. You rarely get this signal, because most widgets disconnect themselves from their window before they destroy it, so no widget owns the window at destroy time.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.STRUCTURE_MASK
mask. GDK will enable this mask automatically for all new windows.
- Gtk.Widget.signals.direction_changed(widget, previous_direction)¶
- Signal Name:
direction-changed
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalprevious_direction (
Gtk.TextDirection
) – the previous text direction of widget
The
::direction-changed
signal is emitted when the text direction of a widget changes.
- Gtk.Widget.signals.drag_begin(widget, context)¶
- Signal Name:
drag-begin
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalcontext (
Gdk.DragContext
) – the drag context
The
::drag-begin
signal is emitted on the drag source when a drag is started. A typical reason to connect to this signal is to set up a custom drag icon with e.g.Gtk.Widget.drag_source_set_icon_pixbuf
().Note that some widgets set up a drag icon in the default handler of this signal, so you may have to use g_signal_connect_after() to override what the default handler did.
- Gtk.Widget.signals.drag_data_delete(widget, context)¶
- Signal Name:
drag-data-delete
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalcontext (
Gdk.DragContext
) – the drag context
The
::drag-data-delete
signal is emitted on the drag source when a drag with the actionGdk.DragAction.MOVE
is successfully completed. The signal handler is responsible for deleting the data that has been dropped. What “delete” means depends on the context of the drag operation.
- Gtk.Widget.signals.drag_data_get(widget, context, data, info, time)¶
- Signal Name:
drag-data-get
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalcontext (
Gdk.DragContext
) – the drag contextdata (
Gtk.SelectionData
) – theGtk.SelectionData
to be filled with the dragged datainfo (
int
) – the info that has been registered with the target in theGtk.TargetList
time (
int
) – the timestamp at which the data was requested
The
::drag-data-get
signal is emitted on the drag source when the drop site requests the data which is dragged. It is the responsibility of the signal handler to fill data with the data in the format which is indicated by info. SeeGtk.SelectionData.set
() andGtk.SelectionData.set_text
().
- Gtk.Widget.signals.drag_data_received(widget, context, x, y, data, info, time)¶
- Signal Name:
drag-data-received
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalcontext (
Gdk.DragContext
) – the drag contextx (
int
) – where the drop happenedy (
int
) – where the drop happeneddata (
Gtk.SelectionData
) – the received datainfo (
int
) – the info that has been registered with the target in theGtk.TargetList
time (
int
) – the timestamp at which the data was received
The
::drag-data-received
signal is emitted on the drop site when the dragged data has been received. If the data was received in order to determine whether the drop will be accepted, the handler is expected to callGdk.drag_status
() and not finish the drag. If the data was received in response to aGtk.Widget
::drag-drop
signal (and this is the last target to be received), the handler for this signal is expected to process the received data and then callGtk.drag_finish
(), setting the success parameter depending on whether the data was processed successfully.Applications must create some means to determine why the signal was emitted and therefore whether to call
Gdk.drag_status
() orGtk.drag_finish
().The handler may inspect the selected action with
Gdk.DragContext.get_selected_action
() before callingGtk.drag_finish
(), e.g. to implementGdk.DragAction.ASK
as shown in the following example:void drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time) { if ((data->length >= 0) && (data->format == 8)) { GdkDragAction action; // handle data here action = gdk_drag_context_get_selected_action (context); if (action == GDK_ACTION_ASK) { GtkWidget *dialog; gint response; dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_YES_NO, "Move the data ?\n"); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_YES) action = GDK_ACTION_MOVE; else action = GDK_ACTION_COPY; } gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time); } else gtk_drag_finish (context, FALSE, FALSE, time); }
- Gtk.Widget.signals.drag_drop(widget, context, x, y, time)¶
- Signal Name:
drag-drop
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalcontext (
Gdk.DragContext
) – the drag contextx (
int
) – the x coordinate of the current cursor positiony (
int
) – the y coordinate of the current cursor positiontime (
int
) – the timestamp of the motion event
- Returns:
whether the cursor position is in a drop zone
- Return type:
The
::drag-drop
signal is emitted on the drop site when the user drops the data onto the widget. The signal handler must determine whether the cursor position is in a drop zone or not. If it is not in a drop zone, it returnsFalse
and no further processing is necessary. Otherwise, the handler returnsTrue
. In this case, the handler must ensure thatGtk.drag_finish
() is called to let the source know that the drop is done. The call toGtk.drag_finish
() can be done either directly or in aGtk.Widget
::drag-data-received
handler which gets triggered by callingGtk.Widget.drag_get_data
() to receive the data for one or more of the supported targets.
- Gtk.Widget.signals.drag_end(widget, context)¶
- Signal Name:
drag-end
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalcontext (
Gdk.DragContext
) – the drag context
The
::drag-end
signal is emitted on the drag source when a drag is finished. A typical reason to connect to this signal is to undo things done inGtk.Widget
::drag-begin
.
- Gtk.Widget.signals.drag_failed(widget, context, result)¶
- Signal Name:
drag-failed
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalcontext (
Gdk.DragContext
) – the drag contextresult (
Gtk.DragResult
) – the result of the drag operation
- Returns:
True
if the failed drag operation has been already handled.- Return type:
The
::drag-failed
signal is emitted on the drag source when a drag has failed. The signal handler may hook custom code to handle a failed DnD operation based on the type of error, it returnsTrue
is the failure has been already handled (not showing the default “drag operation failed” animation), otherwise it returnsFalse
.New in version 2.12.
- Gtk.Widget.signals.drag_leave(widget, context, time)¶
- Signal Name:
drag-leave
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalcontext (
Gdk.DragContext
) – the drag contexttime (
int
) – the timestamp of the motion event
The
::drag-leave
signal is emitted on the drop site when the cursor leaves the widget. A typical reason to connect to this signal is to undo things done inGtk.Widget
::drag-motion
, e.g. undo highlighting withGtk.Widget.drag_unhighlight
().Likewise, the
Gtk.Widget
::drag-leave
signal is also emitted before the::drag-drop
signal, for instance to allow cleaning up of a preview item created in theGtk.Widget
::drag-motion
signal handler.
- Gtk.Widget.signals.drag_motion(widget, context, x, y, time)¶
- Signal Name:
drag-motion
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalcontext (
Gdk.DragContext
) – the drag contextx (
int
) – the x coordinate of the current cursor positiony (
int
) – the y coordinate of the current cursor positiontime (
int
) – the timestamp of the motion event
- Returns:
whether the cursor position is in a drop zone
- Return type:
The
::drag-motion
signal is emitted on the drop site when the user moves the cursor over the widget during a drag. The signal handler must determine whether the cursor position is in a drop zone or not. If it is not in a drop zone, it returnsFalse
and no further processing is necessary. Otherwise, the handler returnsTrue
. In this case, the handler is responsible for providing the necessary information for displaying feedback to the user, by callingGdk.drag_status
().If the decision whether the drop will be accepted or rejected can’t be made based solely on the cursor position and the type of the data, the handler may inspect the dragged data by calling
Gtk.Widget.drag_get_data
() and defer theGdk.drag_status
() call to theGtk.Widget
::drag-data-received
handler. Note that you must passGtk.DestDefaults.DROP
,Gtk.DestDefaults.MOTION
orGtk.DestDefaults.ALL
toGtk.Widget.drag_dest_set
() when using the drag-motion signal that way.Also note that there is no drag-enter signal. The drag receiver has to keep track of whether he has received any drag-motion signals since the last
Gtk.Widget
::drag-leave
and if not, treat the drag-motion signal as an “enter” signal. Upon an “enter”, the handler will typically highlight the drop site withGtk.Widget.drag_highlight
().static void drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time) { GdkAtom target; PrivateData *private_data = GET_PRIVATE_DATA (widget); if (!private_data->drag_highlight) { private_data->drag_highlight = 1; gtk_drag_highlight (widget); } target = gtk_drag_dest_find_target (widget, context, NULL); if (target == GDK_NONE) gdk_drag_status (context, 0, time); else { private_data->pending_status = gdk_drag_context_get_suggested_action (context); gtk_drag_get_data (widget, context, target, time); } return TRUE; } static void drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *selection_data, guint info, guint time) { PrivateData *private_data = GET_PRIVATE_DATA (widget); if (private_data->suggested_action) { private_data->suggested_action = 0; // We are getting this data due to a request in drag_motion, // rather than due to a request in drag_drop, so we are just // supposed to call gdk_drag_status(), not actually paste in // the data. str = gtk_selection_data_get_text (selection_data); if (!data_is_acceptable (str)) gdk_drag_status (context, 0, time); else gdk_drag_status (context, private_data->suggested_action, time); } else { // accept the drop } }
- Gtk.Widget.signals.draw(widget, cr)¶
- Signal Name:
draw
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalcr (
cairo.Context
) – the cairo context to draw to
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
This signal is emitted when a widget is supposed to render itself. The widget's top left corner must be painted at the origin of the passed in context and be sized to the values returned by
Gtk.Widget.get_allocated_width
() andGtk.Widget.get_allocated_height
().Signal handlers connected to this signal can modify the cairo context passed as cr in any way they like and don’t need to restore it. The signal emission takes care of calling
cairo.Context.save
() before andcairo.Context.restore
() after invoking the handler.The signal handler will get a cr with a clip region already set to the widget’s dirty region, i.e. to the area that needs repainting. Complicated widgets that want to avoid redrawing themselves completely can get the full extents of the clip region with
Gdk.cairo_get_clip_rectangle
(), or they can get a finer-grained representation of the dirty region withcairo.Context.copy_clip_rectangle_list
().New in version 3.0.
- Gtk.Widget.signals.enter_notify_event(widget, event)¶
- Signal Name:
enter-notify-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventCrossing
) – theGdk.EventCrossing
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::enter-notify-event
will be emitted when the pointer enters the widget's window.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.ENTER_NOTIFY_MASK
mask.This signal will be sent to the grab widget if there is one.
- Gtk.Widget.signals.event(widget, event)¶
- Signal Name:
event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.Event
) – theGdk.Event
which triggered this signal
- Returns:
True
to stop other handlers from being invoked for the event and to cancel the emission of the second specific::event
signal.False
to propagate the event further and to allow the emission of the second signal. The::event-after
signal is emitted regardless of the return value.- Return type:
The GTK+ main loop will emit three signals for each GDK event delivered to a widget: one generic
::event
signal, another, more specific, signal that matches the type of event delivered (e.g.Gtk.Widget
::key-press-event
) and finally a genericGtk.Widget
::event-after
signal.
- Gtk.Widget.signals.event_after(widget, event)¶
- Signal Name:
event-after
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.Event
) – theGdk.Event
which triggered this signal
After the emission of the
Gtk.Widget
::event
signal and (optionally) the second more specific signal,::event-after
will be emitted regardless of the previous two signals handlers return values.
- Gtk.Widget.signals.focus(widget, direction)¶
- Signal Name:
focus
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signaldirection (
Gtk.DirectionType
) –
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
- Gtk.Widget.signals.focus_in_event(widget, event)¶
- Signal Name:
focus-in-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventFocus
) – theGdk.EventFocus
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::focus-in-event
signal will be emitted when the keyboard focus enters the widget's window.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.FOCUS_CHANGE_MASK
mask.
- Gtk.Widget.signals.focus_out_event(widget, event)¶
- Signal Name:
focus-out-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventFocus
) – theGdk.EventFocus
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::focus-out-event
signal will be emitted when the keyboard focus leaves the widget's window.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.FOCUS_CHANGE_MASK
mask.
- Gtk.Widget.signals.grab_broken_event(widget, event)¶
- Signal Name:
grab-broken-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventGrabBroken
) – theGdk.EventGrabBroken
event
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
Emitted when a pointer or keyboard grab on a window belonging to widget gets broken.
On X11, this happens when the grab window becomes unviewable (i.e. it or one of its ancestors is unmapped), or if the same application grabs the pointer or keyboard again.
New in version 2.8.
- Gtk.Widget.signals.grab_focus(widget)¶
- Signal Name:
grab-focus
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
- Gtk.Widget.signals.grab_notify(widget, was_grabbed)¶
- Signal Name:
grab-notify
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalwas_grabbed (
bool
) –False
if the widget becomes shadowed,True
if it becomes unshadowed
The
::grab-notify
signal is emitted when a widget becomes shadowed by a GTK+ grab (not a pointer or keyboard grab) on another widget, or when it becomes unshadowed due to a grab being removed.A widget is shadowed by a
Gtk.Widget.grab_add
() when the topmost grab widget in the grab stack of its window group is not its ancestor.
- Gtk.Widget.signals.hide(widget)¶
- Signal Name:
hide
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
The
::hide
signal is emitted when widget is hidden, for example withGtk.Widget.hide
().
- Gtk.Widget.signals.hierarchy_changed(widget, previous_toplevel)¶
- Signal Name:
hierarchy-changed
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalprevious_toplevel (
Gtk.Widget
orNone
) – the previous toplevel ancestor, orNone
if the widget was previously unanchored
The
::hierarchy-changed
signal is emitted when the anchored state of a widget changes. A widget is “anchored” when its toplevel ancestor is aGtk.Window
. This signal is emitted when a widget changes from un-anchored to anchored or vice-versa.
- Gtk.Widget.signals.key_press_event(widget, event)¶
- Signal Name:
key-press-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventKey
) – theGdk.EventKey
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::key-press-event
signal is emitted when a key is pressed. The signal emission will reoccur at the key-repeat rate when the key is kept pressed.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.KEY_PRESS_MASK
mask.This signal will be sent to the grab widget if there is one.
- Gtk.Widget.signals.key_release_event(widget, event)¶
- Signal Name:
key-release-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventKey
) – theGdk.EventKey
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::key-release-event
signal is emitted when a key is released.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.KEY_RELEASE_MASK
mask.This signal will be sent to the grab widget if there is one.
- Signal Name:
keynav-failed
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signaldirection (
Gtk.DirectionType
) – the direction of movement
- Returns:
True
if stopping keyboard navigation is fine,False
if the emitting widget should try to handle the keyboard navigation attempt in its parent container(s).- Return type:
Gets emitted if keyboard navigation fails. See
Gtk.Widget.keynav_failed
() for details.New in version 2.12.
- Gtk.Widget.signals.leave_notify_event(widget, event)¶
- Signal Name:
leave-notify-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventCrossing
) – theGdk.EventCrossing
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::leave-notify-event
will be emitted when the pointer leaves the widget's window.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.LEAVE_NOTIFY_MASK
mask.This signal will be sent to the grab widget if there is one.
- Gtk.Widget.signals.map(widget)¶
- Signal Name:
map
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
The
::map
signal is emitted when widget is going to be mapped, that is when the widget is visible (which is controlled withGtk.Widget.set_visible
()) and all its parents up to the toplevel widget are also visible. Once the map has occurred,Gtk.Widget
::map-event
will be emitted.The
::map
signal can be used to determine whether a widget will be drawn, for instance it can resume an animation that was stopped during the emission ofGtk.Widget
::unmap
.
- Gtk.Widget.signals.map_event(widget, event)¶
- Signal Name:
map-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventAny
) – theGdk.EventAny
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::map-event
signal will be emitted when the widget's window is mapped. A window is mapped when it becomes visible on the screen.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.STRUCTURE_MASK
mask. GDK will enable this mask automatically for all new windows.
- Gtk.Widget.signals.mnemonic_activate(widget, group_cycling)¶
- Signal Name:
mnemonic-activate
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalgroup_cycling (
bool
) –True
if there are other widgets with the same mnemonic
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The default handler for this signal activates widget if group_cycling is
False
, or just makes widget grab focus if group_cycling isTrue
.
- Gtk.Widget.signals.motion_notify_event(widget, event)¶
- Signal Name:
motion-notify-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventMotion
) – theGdk.EventMotion
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::motion-notify-event
signal is emitted when the pointer moves over the widget’sGdk.Window
.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.POINTER_MOTION_MASK
mask.This signal will be sent to the grab widget if there is one.
- Gtk.Widget.signals.move_focus(widget, direction)¶
- Signal Name:
move-focus
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signaldirection (
Gtk.DirectionType
) –
- Gtk.Widget.signals.parent_set(widget, old_parent)¶
- Signal Name:
parent-set
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalold_parent (
Gtk.Widget
orNone
) – the previous parent, orNone
if the widget just got its initial parent.
The
::parent-set
signal is emitted when a new parent has been set on a widget.
- Signal Name:
popup-menu
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal- Returns:
True
if a menu was activated- Return type:
This signal gets emitted whenever a widget should pop up a context menu. This usually happens through the standard key binding mechanism; by pressing a certain key while a widget is focused, the user can cause the widget to pop up a menu. For example, the
Gtk.Entry
widget creates a menu with clipboard commands. See the Popup Menu Migration Checklist for an example of how to use this signal.
- Gtk.Widget.signals.property_notify_event(widget, event)¶
- Signal Name:
property-notify-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventProperty
) – theGdk.EventProperty
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::property-notify-event
signal will be emitted when a property on the widget's window has been changed or deleted.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.PROPERTY_CHANGE_MASK
mask.
- Gtk.Widget.signals.proximity_in_event(widget, event)¶
- Signal Name:
proximity-in-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventProximity
) – theGdk.EventProximity
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
To receive this signal the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.PROXIMITY_IN_MASK
mask.This signal will be sent to the grab widget if there is one.
- Gtk.Widget.signals.proximity_out_event(widget, event)¶
- Signal Name:
proximity-out-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventProximity
) – theGdk.EventProximity
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
To receive this signal the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.PROXIMITY_OUT_MASK
mask.This signal will be sent to the grab widget if there is one.
- Gtk.Widget.signals.query_tooltip(widget, x, y, keyboard_mode, tooltip)¶
- Signal Name:
query-tooltip
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalx (
int
) – the x coordinate of the cursor position where the request has been emitted, relative to widget's left sidey (
int
) – the y coordinate of the cursor position where the request has been emitted, relative to widget's topkeyboard_mode (
bool
) –True
if the tooltip was triggered using the keyboardtooltip (
Gtk.Tooltip
) – aGtk.Tooltip
- Returns:
- Return type:
Emitted when
Gtk.Widget
:has-tooltip
isTrue
and the hover timeout has expired with the cursor hovering “above” widget; or emitted when widget got focus in keyboard mode.Using the given coordinates, the signal handler should determine whether a tooltip should be shown for widget. If this is the case
True
should be returned,False
otherwise. Note that if keyboard_mode isTrue
, the values of x and y are undefined and should not be used.The signal handler is free to manipulate tooltip with the therefore destined function calls.
New in version 2.12.
- Gtk.Widget.signals.realize(widget)¶
- Signal Name:
realize
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
The
::realize
signal is emitted when widget is associated with aGdk.Window
, which means thatGtk.Widget.realize
() has been called or the widget has been mapped (that is, it is going to be drawn).
- Gtk.Widget.signals.screen_changed(widget, previous_screen)¶
- Signal Name:
screen-changed
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalprevious_screen (
Gdk.Screen
orNone
) – the previous screen, orNone
if the widget was not associated with a screen before
The
::screen-changed
signal gets emitted when the screen of a widget has changed.
- Gtk.Widget.signals.scroll_event(widget, event)¶
- Signal Name:
scroll-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventScroll
) – theGdk.EventScroll
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::scroll-event
signal is emitted when a button in the 4 to 7 range is pressed. Wheel mice are usually configured to generate button press events for buttons 4 and 5 when the wheel is turned.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.SCROLL_MASK
mask.This signal will be sent to the grab widget if there is one.
- Gtk.Widget.signals.selection_clear_event(widget, event)¶
- Signal Name:
selection-clear-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventSelection
) – theGdk.EventSelection
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::selection-clear-event
signal will be emitted when the the widget's window has lost ownership of a selection.
- Gtk.Widget.signals.selection_get(widget, data, info, time)¶
- Signal Name:
selection-get
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signaldata (
Gtk.SelectionData
) –info (
int
) –time (
int
) –
- Gtk.Widget.signals.selection_notify_event(widget, event)¶
- Signal Name:
selection-notify-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventSelection
) –
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
- Gtk.Widget.signals.selection_received(widget, data, time)¶
- Signal Name:
selection-received
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signaldata (
Gtk.SelectionData
) –time (
int
) –
- Gtk.Widget.signals.selection_request_event(widget, event)¶
- Signal Name:
selection-request-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventSelection
) – theGdk.EventSelection
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::selection-request-event
signal will be emitted when another client requests ownership of the selection owned by the widget's window.
- Gtk.Widget.signals.show(widget)¶
- Signal Name:
show
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
The
::show
signal is emitted when widget is shown, for example withGtk.Widget.show
().
- Gtk.Widget.signals.show_help(widget, help_type)¶
- Signal Name:
show-help
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalhelp_type (
Gtk.WidgetHelpType
) –
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
- Gtk.Widget.signals.size_allocate(widget, allocation)¶
- Signal Name:
size-allocate
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalallocation (
Gdk.Rectangle
) – the region which has been allocated to the widget.
- Gtk.Widget.signals.state_changed(widget, state)¶
- Signal Name:
state-changed
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalstate (
Gtk.StateType
) – the previous state
The
::state-changed
signal is emitted when the widget state changes. SeeGtk.Widget.get_state
().Deprecated since version 3.0: Use
Gtk.Widget
::state-flags-changed
instead.
- Gtk.Widget.signals.state_flags_changed(widget, flags)¶
- Signal Name:
state-flags-changed
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalflags (
Gtk.StateFlags
) – The previous state flags.
The
::state-flags-changed
signal is emitted when the widget state changes, seeGtk.Widget.get_state_flags
().New in version 3.0.
- Gtk.Widget.signals.style_set(widget, previous_style)¶
- Signal Name:
style-set
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalprevious_style (
Gtk.Style
orNone
) – the previous style, orNone
if the widget just got its initial style
The
::style-set
signal is emitted when a new style has been set on a widget. Note that style-modifying functions likeGtk.Widget.modify_base
() also cause this signal to be emitted.Note that this signal is emitted for changes to the deprecated
Gtk.Style
. To track changes to theGtk.StyleContext
associated with a widget, use theGtk.Widget
::style-updated
signal.Deprecated since version 3.0: Use the
Gtk.Widget
::style-updated
signal
- Gtk.Widget.signals.style_updated(widget)¶
- Signal Name:
style-updated
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
The
::style-updated
signal is a convenience signal that is emitted when theGtk.StyleContext
::changed
signal is emitted on the widget's associatedGtk.StyleContext
as returned byGtk.Widget.get_style_context
().Note that style-modifying functions like
Gtk.Widget.override_color
() also cause this signal to be emitted.New in version 3.0.
- Gtk.Widget.signals.touch_event(widget, object)¶
- Signal Name:
touch-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalobject (
Gdk.Event
) –
- Return type:
- Gtk.Widget.signals.unmap(widget)¶
- Signal Name:
unmap
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
The
::unmap
signal is emitted when widget is going to be unmapped, which means that either it or any of its parents up to the toplevel widget have been set as hidden.As
::unmap
indicates that a widget will not be shown any longer, it can be used to, for example, stop an animation on the widget.
- Gtk.Widget.signals.unmap_event(widget, event)¶
- Signal Name:
unmap-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventAny
) – theGdk.EventAny
which triggered this signal
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::unmap-event
signal will be emitted when the widget's window is unmapped. A window is unmapped when it becomes invisible on the screen.To receive this signal, the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.STRUCTURE_MASK
mask. GDK will enable this mask automatically for all new windows.
- Gtk.Widget.signals.unrealize(widget)¶
- Signal Name:
unrealize
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signal
The
::unrealize
signal is emitted when theGdk.Window
associated with widget is destroyed, which means thatGtk.Widget.unrealize
() has been called or the widget has been unmapped (that is, it is going to be hidden).
- Gtk.Widget.signals.visibility_notify_event(widget, event)¶
- Signal Name:
visibility-notify-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventVisibility
) – theGdk.EventVisibility
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::visibility-notify-event
will be emitted when the widget's window is obscured or unobscured.To receive this signal the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.VISIBILITY_NOTIFY_MASK
mask.Deprecated since version 3.12: Modern composited windowing systems with pervasive transparency make it impossible to track the visibility of a window reliably, so this signal can not be guaranteed to provide useful information.
- Gtk.Widget.signals.window_state_event(widget, event)¶
- Signal Name:
window-state-event
- Flags:
- Parameters:
widget (
Gtk.Widget
) – The object which received the signalevent (
Gdk.EventWindowState
) – theGdk.EventWindowState
which triggered this signal.
- Returns:
True
to stop other handlers from being invoked for the event.False
to propagate the event further.- Return type:
The
::window-state-event
will be emitted when the state of the toplevel window associated to the widget changes.To receive this signal the
Gdk.Window
associated to the widget needs to enable theGdk.EventMask.STRUCTURE_MASK
mask. GDK will enable this mask automatically for all new windows.
Property Details¶
- Gtk.Widget.props.app_paintable¶
- Name:
app-paintable
- Type:
- Default Value:
- Flags:
Whether the application will paint directly on the widget
- Gtk.Widget.props.can_default¶
- Name:
can-default
- Type:
- Default Value:
- Flags:
Whether the widget can be the default widget
- Gtk.Widget.props.can_focus¶
- Name:
can-focus
- Type:
- Default Value:
- Flags:
Whether the widget can accept the input focus
- Gtk.Widget.props.composite_child¶
-
Whether the widget is part of a composite widget
- Gtk.Widget.props.double_buffered¶
- Name:
double-buffered
- Type:
- Default Value:
- Flags:
Whether the widget is double buffered.
New in version 2.18.
Deprecated since version 3.14: Widgets should not use this property.
- Gtk.Widget.props.events¶
- Name:
events
- Type:
- Default Value:
Gdk.EventMask.STRUCTURE_MASK
|Gdk.EventMask.ALL_EVENTS_MASK
- Flags:
The event mask that decides what kind of GdkEvents this widget gets
- Gtk.Widget.props.expand¶
-
Whether to expand in both directions. Setting this sets both
Gtk.Widget
:hexpand
andGtk.Widget
:vexpand
New in version 3.0.
- Gtk.Widget.props.focus_on_click¶
- Name:
focus-on-click
- Type:
- Default Value:
- Flags:
Whether the widget should grab focus when it is clicked with the mouse.
This property is only relevant for widgets that can take focus.
Before 3.20, several widgets (
Gtk.Button
,Gtk.FileChooserButton
,Gtk.ComboBox
) implemented this property individually.New in version 3.20.
- Gtk.Widget.props.halign¶
- Name:
halign
- Type:
- Default Value:
- Flags:
How to distribute horizontal space if widget gets extra space, see
Gtk.Align
New in version 3.0.
- Gtk.Widget.props.has_default¶
- Name:
has-default
- Type:
- Default Value:
- Flags:
Whether the widget is the default widget
- Gtk.Widget.props.has_focus¶
- Name:
has-focus
- Type:
- Default Value:
- Flags:
Whether the widget has the input focus
- Gtk.Widget.props.has_tooltip¶
- Name:
has-tooltip
- Type:
- Default Value:
- Flags:
Enables or disables the emission of
Gtk.Widget
::query-tooltip
on widget. A value ofTrue
indicates that widget can have a tooltip, in this case the widget will be queried usingGtk.Widget
::query-tooltip
to determine whether it will provide a tooltip or not.Note that setting this property to
True
for the first time will change the event masks of the GdkWindows of this widget to include leave-notify and motion-notify events. This cannot and will not be undone when the property is set toFalse
again.New in version 2.12.
- Gtk.Widget.props.height_request¶
- Name:
height-request
- Type:
- Default Value:
-1
- Flags:
Override for height request of the widget, or -1 if natural request should be used
- Gtk.Widget.props.hexpand¶
- Name:
hexpand
- Type:
- Default Value:
- Flags:
Whether to expand horizontally. See
Gtk.Widget.set_hexpand
().New in version 3.0.
- Gtk.Widget.props.hexpand_set¶
- Name:
hexpand-set
- Type:
- Default Value:
- Flags:
Whether to use the
Gtk.Widget
:hexpand
property. SeeGtk.Widget.get_hexpand_set
().New in version 3.0.
- Gtk.Widget.props.is_focus¶
-
Whether the widget is the focus widget within the toplevel
- Gtk.Widget.props.margin¶
-
Sets all four sides’ margin at once. If read, returns max margin on any side.
New in version 3.0.
- Gtk.Widget.props.margin_bottom¶
- Name:
margin-bottom
- Type:
- Default Value:
0
- Flags:
Margin on bottom side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from
Gtk.Widget.set_size_request
() for example.New in version 3.0.
- Gtk.Widget.props.margin_end¶
- Name:
margin-end
- Type:
- Default Value:
0
- Flags:
Margin on end of widget, horizontally. This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from
Gtk.Widget.set_size_request
() for example.New in version 3.12.
- Gtk.Widget.props.margin_left¶
- Name:
margin-left
- Type:
- Default Value:
0
- Flags:
Margin on left side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from
Gtk.Widget.set_size_request
() for example.New in version 3.0.
Deprecated since version 3.12: Use
Gtk.Widget
:margin-start
instead.
- Gtk.Widget.props.margin_right¶
- Name:
margin-right
- Type:
- Default Value:
0
- Flags:
Margin on right side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from
Gtk.Widget.set_size_request
() for example.New in version 3.0.
Deprecated since version 3.12: Use
Gtk.Widget
:margin-end
instead.
- Gtk.Widget.props.margin_start¶
- Name:
margin-start
- Type:
- Default Value:
0
- Flags:
Margin on start of widget, horizontally. This property supports left-to-right and right-to-left text directions.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from
Gtk.Widget.set_size_request
() for example.New in version 3.12.
- Gtk.Widget.props.margin_top¶
- Name:
margin-top
- Type:
- Default Value:
0
- Flags:
Margin on top side of widget.
This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from
Gtk.Widget.set_size_request
() for example.New in version 3.0.
- Gtk.Widget.props.name¶
-
The name of the widget
- Gtk.Widget.props.no_show_all¶
- Name:
no-show-all
- Type:
- Default Value:
- Flags:
Whether
Gtk.Widget.show_all
() should not affect this widget
- Gtk.Widget.props.opacity¶
- Name:
opacity
- Type:
- Default Value:
1.0
- Flags:
The requested opacity of the widget. See
Gtk.Widget.set_opacity
() for more details about window opacity.Before 3.8 this was only available in
Gtk.Window
New in version 3.8.
- Gtk.Widget.props.parent¶
- Name:
parent
- Type:
- Default Value:
- Flags:
The parent widget of this widget. Must be a Container widget
- Gtk.Widget.props.receives_default¶
- Name:
receives-default
- Type:
- Default Value:
- Flags:
If
True
, the widget will receive the default action when it is focused
- Gtk.Widget.props.scale_factor¶
-
The scale factor of the widget. See
Gtk.Widget.get_scale_factor
() for more details about widget scaling.New in version 3.10.
- Gtk.Widget.props.sensitive¶
- Name:
sensitive
- Type:
- Default Value:
- Flags:
Whether the widget responds to input
- Gtk.Widget.props.style¶
- Name:
style
- Type:
- Default Value:
- Flags:
The style of the widget, which contains information about how it will look (colors, etc).
Deprecated since version ???: Use
Gtk.StyleContext
instead
- Gtk.Widget.props.tooltip_markup¶
-
Sets the text of tooltip to be the given string, which is marked up with the Pango text markup language. Also see
Gtk.Tooltip.set_markup
().This is a convenience property which will take care of getting the tooltip shown if the given string is not
None
:Gtk.Widget
:has-tooltip
will automatically be set toTrue
and there will be taken care ofGtk.Widget
::query-tooltip
in the default signal handler.Note that if both
Gtk.Widget
:tooltip-text
andGtk.Widget
:tooltip-markup
are set, the last one wins.New in version 2.12.
- Gtk.Widget.props.tooltip_text¶
-
Sets the text of tooltip to be the given string.
Also see
Gtk.Tooltip.set_text
().This is a convenience property which will take care of getting the tooltip shown if the given string is not
None
:Gtk.Widget
:has-tooltip
will automatically be set toTrue
and there will be taken care ofGtk.Widget
::query-tooltip
in the default signal handler.Note that if both
Gtk.Widget
:tooltip-text
andGtk.Widget
:tooltip-markup
are set, the last one wins.New in version 2.12.
- Gtk.Widget.props.valign¶
- Name:
valign
- Type:
- Default Value:
- Flags:
How to distribute vertical space if widget gets extra space, see
Gtk.Align
New in version 3.0.
- Gtk.Widget.props.vexpand¶
- Name:
vexpand
- Type:
- Default Value:
- Flags:
Whether to expand vertically. See
Gtk.Widget.set_vexpand
().New in version 3.0.
- Gtk.Widget.props.vexpand_set¶
- Name:
vexpand-set
- Type:
- Default Value:
- Flags:
Whether to use the
Gtk.Widget
:vexpand
property. SeeGtk.Widget.get_vexpand_set
().New in version 3.0.
- Gtk.Widget.props.visible¶
- Name:
visible
- Type:
- Default Value:
- Flags:
Whether the widget is visible
- Gtk.Widget.props.width_request¶
- Name:
width-request
- Type:
- Default Value:
-1
- Flags:
Override for width request of the widget, or -1 if natural request should be used