Gtk.Widget


Gtk.Widget — Base class for all widgets

Object Hierarchy:

    GBoxed
    ╰── Gtk.Requisition
    GObject
    ╰── GInitiallyUnowned
        ╰── Gtk.Widget
            ├── Gtk.Container
            ├── Gtk.Misc
            ├── Gtk.Calendar
            ├── Gtk.CellView
            ├── Gtk.DrawingArea
            ├── Gtk.Entry
            ├── Gtk.GLArea
            ├── Gtk.Range
            ├── Gtk.Separator
            ├── Gtk.HSV
            ├── Gtk.Invisible
            ├── Gtk.ProgressBar
            ├── Gtk.Spinner
            ├── Gtk.Switch
            ╰── Gtk.LevelBar

Functions:


Signals:

  • “accel-closures-changed” (widget, user_data)
  • “button-press-event” (widget, event, user_data)
  • “button-release-event” (widget, event, user_data)
  • “can-activate-accel” (widget, signal_id, user_data)
  • “child-notify” (widget, child_property, user_data)
  • “composited-changed” (widget, user_data)
  • “configure-event” (widget, event, user_data)
  • “damage-event” (widget, event, user_data)
  • “delete-event” (widget, event, user_data)
  • “destroy” (object, user_data)
  • “destroy-event” (widget, event, user_data)
  • “direction-changed” (widget, previous_direction, user_data)
  • “drag-begin” (widget, context, user_data)
  • “drag-data-delete” (widget, context, user_data)
  • “drag-data-get” (widget, context, data, info, time, user_data)
  • “drag-data-received” (widget, context, x, y, data, info, time, user_data)
  • “drag-drop” (widget, context, x, y, time, user_data)
  • “drag-end” (widget, context, user_data)
  • “drag-failed” (widget, context, result, user_data)
  • “drag-leave” (widget, context, time, user_data)
  • “drag-motion” (widget, context, x, y, time, user_data)
  • “draw” (widget, cr, user_data)
  • “enter-notify-event” (widget, event, user_data)
  • “event” (widget, event, user_data)
  • “event-after” (widget, event, user_data)
  • “focus” (widget, user_data)
  • “focus-in-event” (widget, event, user_data)
  • “focus-out-event” (widget, event, user_data)
  • “grab-broken-event” (widget, event, user_data)
  • “grab-focus” (widget, user_data)
  • “grab-notify” (widget, was_grabbed, user_data)
  • “hide” (widget, user_data)
  • “hierarchy-changed” (widget, previous_toplevel, user_data)
  • “key-press-event” (widget, event, user_data)
  • “key-release-event” (widget, event, user_data)
  • “keynav-failed” (widget, direction, user_data)
  • “leave-notify-event” (widget, event, user_data)
  • “map” (widget, user_data)
  • “map-event” (widget, event, user_data)
  • “mnemonic-activate” (widget, user_data)
  • “motion-notify-event” (widget, event, user_data)
  • “move-focus” (widget, user_data)
  • “parent-set” (widget, old_parent, user_data)
  • “popup-menu” (widget, user_data)
  • “property-notify-event” (widget, event, user_data)
  • “proximity-in-event” (widget, event, user_data)
  • “proximity-out-event” (widget, event, user_data)
  • “query-tooltip” (widget, x, y, keyboard_mode, tooltip, user_data)
  • “realize” (widget, user_data)
  • “screen-changed” (widget, previous_screen, user_data)
  • “scroll-event” (widget, event, user_data)
  • “selection-clear-event” (widget, event, user_data)
  • “selection-get” (widget, user_data)
  • “selection-notify-event” (widget, event, user_data)
  • “selection-received” (widget, user_data)
  • “selection-request-event” (widget, event, user_data)
  • “show” (widget, user_data)
  • “show-help” (widget, user_data)
  • “size-allocate” (widget, allocation, user_data)
  • “state-changed” (widget, state, user_data)
  • “state-flags-changed” (widget, flags, user_data)
  • “style-updated” (widget, previous_style, user_data)
  • “style-updated” (widget, user_data)
  • “touch-event” (widget, user_data)
  • “unmap” (widget, user_data)
  • “unmap-event” (widget, event, user_data)
  • “unrealize” (widget, user_data)
  • “visibility-notify-event” (widget, event, user_data)
  • “window-state-event” (widget, event, user_data)

Description:

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:

  • Gtk.WidgetClass.get_request_mode()
  • Gtk.WidgetClass.get_preferred_width()
  • Gtk.WidgetClass.get_preferred_height()
  • Gtk.WidgetClass.get_preferred_height_for_width()
  • Gtk.WidgetClass.get_preferred_width_for_height()
  • Gtk.WidgetClass.get_preferred_height_and_baseline_for_width() 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_SIZE_REQUEST_HEIGHT_FOR_WIDTH mode: First, the default minimum and natural width for each widget in the interface will be computed using Gtk.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 using Gtk.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 (unless Gtk.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 a Gtk.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 [Gtk.Container’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 have Gtk.WidgetClass::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_SIZE_REQUEST_HEIGHT_FOR_WIDTH widget generally deals with width-for-height requests, for Gtk.WidgetClass::get_preferred_height()

def get_preferred_height (widget):
   if i_am_in_height_for_width_mode:     
       min_width, nat_width = widget.get_preferred_width ()
       min_height, nat_height = widget.get_preferred_height_for_width(min_width)
   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.       
    return min_height, nat_height

And in Gtk.WidgetClass::get_preferred_width_for_height() it will simply return the minimum and natural width:

def get_preferred_width_for_height(widget, for_height)
    if i_am_in_height_for_width_mode:
        min_width, nat_width = widget.get_preferred_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.
    return min_width, nat_width
}

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:

min_width, nat_width = widget.get_preferred_width()

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 by Gtk.SizeGroup and by the Gtk.WidgetClass.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.WidgetClass.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 the Gtk.WidgetClass.get_preferred_height() and Gtk.WidgetClass.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 via Gtk.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][gtk3-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() or Gtk.WidgetClass::list_style_properties() to get information about existing style properties and Gtk.WidgetStyle::get_property(), Gtk.WidgetStyle::get() or Gtk.WidgetStyle::get_valist() to obtain the value of a style property.

Gt.kWidget as Gtk.Buildable

The Gtk.Widget implementation of the Gtk.Buildable interface supports a custom \ 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 \ element, which supports actions and relations. Properties on the accessible implementation of an object can be set by accessing the internal child accessible of a Gtk.Widget.

An example of a UI definition fragment specifying an accessible:

<object class="GtkButton" 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 \ 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 using Gtk.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 using Gtk.Widget::class_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 \ tag as a direct child of the toplevel \ tag. The \ 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 the Gtk.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 \ tag behaves as if it were added to the \ tag defining widget itself. You may set properties on widget by inserting \ tags into the \ tag, and also add \ tags to add children and extend widget in the normal way you would with \ tags.

Additionally, \ tags can also be added before and after the initial \ tag in the normal way, allowing one to define auxiliary objects which might be referenced by other widgets declared as children of the \ 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 call Gtk.WidgetClass::set_template_from_resource() from the class initialization of your Gtk.Widget type:

class FooWidgetClass(Gtk.WidgetClass):
    def __init__(self):
        super().__init__()

        # ...

        self.set_template_from_resource ("/com/example/ui/foowidget.ui")

You will also need to call Gtk.Widget::init_template() from the instance initialization function:

class FooWidget(Gtk.Widget):
    def __init__(self):
        super().__init__()    
        self.init_template()

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.WidgetClass::bind_template_child_private() with that name, e.g.


class FooWidgetClass(Gtk.WidgetClass):
    def __init__(self):
        super().__init__()
        # ...

        self.set_template_from_resource ("/com/example/ui/foowidget.ui")
        self.bind_template_child_private (FooWidget, hello_button)
        self.bind_template_child_private (FooWidget, goodbye_button)

You can also use Gtk.WidgetClass::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

def on_hello_button_clicked (widget, event):
    print ("Hello, world!\n")

class FooWidgetClass(Gtk.WidgetClass):
    def __init__(self):
        super().__init__()
        # ...

        self.set_template_from_resource ("/com/example/ui/foowidget.ui")
        self.bind_template_callback (on_hello_button_clicked)

Function Details:

new()

new (object_type:GType, parameters:list) -> GObject.Object

This is a convenience function for creating a widget and settingits properties in one go. For example you might write:Gtk.Widget:new (GTK_TYPE_LABEL, "label", "Hello World", "xalign",0.0, None) to create a left-aligned label. Equivalent tog_object_new(), but returns a widget so you don’t have tocast the object yourself.

  • Returns: a new Gtk.Widget of type widget_type

destroy()

destroy (self)

Destroys a widget. When a widget isdestroyed, it will break any references it holds to other objects.If the widget is inside a container, the widget will be removedfrom the container. If the widget is a toplevel (derived fromGtk.Window), it will be removed from the list of toplevels, and thereference GTK+ holds to it will be removed. Removing awidget from its container or the list of toplevels results in thewidget being finalized, unless you’ve added additional referencesto the widget with g_object_ref(). In most cases, only toplevel widgets (windows) require explicitdestruction, because when you destroy a toplevel its children willbe destroyed as well.


in_destruction()

in_destruction (self) -> bool

Returns whether the widget is currently being destroyed.This information can sometimes be used to avoid doingunnecessary work.

  • Returns: True if widgetis being destroyed

destroyed()

destroyed (self, widget_pointer:Gtk.Widget) -> 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 connect Gtk.Widget:destroyed()as a signal handler, and pass the address of your widget variableas user data. Then when the widget is destroyed, the variable willbe set to None. Useful for example to avoid multiple copiesof the same dialog.


unparent()

unparent (self)

This function is only for use in widget implementations.Should be called by implementations of the remove methodon Gtk.Container, to dissociate a child from the container.


show()

show (self)

Flags a widget to be displayed. Any widget that isn’t shown willnot appear on the screen. If you want to show all the widgets in acontainer, it’s easier to call Gtk.Widget:show_all() on thecontainer, 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 andmapped; other shown widgets are realized and mapped when theirtoplevel container is realized and mapped.


show_now()

show_now (self)

Shows a widget. If the widget is an unmapped toplevel widget(i.e. a Gtk.Window that has not yet been shown), enter the mainloop and wait for the window to actually be mapped. Be careful;because the main loop is running, anything can happen duringthis function.


hide()

hide (self)

Reverses the effects of Gtk.Widget:show(), causing the widget to behidden (invisible to the user).


show_all()

show_all (self)

Recursively shows a widget, and any child widgets (if the widget isa container).


map()

map (self)

This function is only for use in widget implementations. Causesa widget to be mapped if it isn’t already.


unmap()

unmap (self)

This function is only for use in widget implementations. Causesa widget to be unmapped if it’s currently mapped.


realize()

realize (self)

Creates the GDK (windowing system) resources associated with awidget. For example, widget-&gt;window will be created when a widgetis realized. Normally realization happens implicitly; if you showa widget and all its parent containers, then the widget will berealized and mapped automatically. Realizing a widget requires allthe widget’s parent widgets to be realized; callingGtk.Widget:realize() realizes the widget’s parents in addition towidget itself. If a widget is not yet inside a toplevel windowwhen you realize it, bad things will happen. This function is primarily used in widget implementations, andisn’t very useful otherwise. Many times when you think you mightneed it, a better approach is to connect to a signal that will becalled after the widget is realized automatically, such as“draw”. Or simply g_signal_connect() to the“realize” signal.


unrealize()

unrealize (self)

This function is only useful in widget implementations.Causes a widget to be unrealized (frees all GDK resourcesassociated with the widget, such as widget-&gt;window).


draw()

draw (self, cr:cairo.Context)

Draws widget to cr. The top left corner of the widget will bedrawn to the currently set origin point of cr. You should pass a cairo context as cr argument that is in anoriginal state. Otherwise the resulting drawing is undefined. Forexample changing the operator using cairo_set_operator() or theline width using cairo_set_line_width() might have unwanted sideeffects.You may however change the context’s transform matrix - like withcairo_scale(), cairo_translate() or cairo_set_matrix() and clipregion with cairo_clip() prior to calling this function. Also, itis fine to modify the context with cairo_save() andcairo_push_group() prior to calling this function. Note that special-purpose widgets may contain special code forrendering to the screen and might appear differently on screenand when rendered using Gtk.Widget:draw().

  • Since: 3.0

queue_draw()

queue_draw (self)

Equivalent to calling Gtk.Widget:queue_draw_area() for theentire area of a widget.


queue_resize()

queue_resize (self)

This function is only for use in widget implementations.Flags a widget to have its size renegotiated; shouldbe called when a widget for some reason has a new size request.For example, when you change the text in a Gtk.Label, Gtk.Labelqueues a resize to ensure there’s enough space for the new text. Note that you cannot call Gtk.Widget:queue_resize() on a widgetfrom inside its implementation of the Gtk.WidgetClass::size_allocate virtual method. Calls to Gtk.Widget:queue_resize() from insideGtk.WidgetClass::size_allocate will be silently ignored.


queue_resize_no_redraw()

queue_resize_no_redraw (self)

This function works like Gtk.Widget:queue_resize(),except that the widget is not invalidated.

  • Since: 2.4

get_frame_clock()

get_frame_clock (self) -> Gdk.FrameClock

Obtains the frame clock for a widget. The frame clock is a global“ticker” that can be used to drive animations and repaints. Themost common reason to get the frame clock is to callgdk_frame_clock_get_frame_time(), in order to get a time to use foranimating. For example you might record the start of the animationwith an initial value from gdk_frame_clock_get_frame_time(), andthen update the animation by callinggdk_frame_clock_get_frame_time() again during each repaint. gdk_frame_clock_request_phase() will result in a new frame on theclock, but won’t necessarily repaint any widgets. To repaint awidget, you have to use Gtk.Widget:queue_draw() which invalidatesthe widget (thus scheduling it to receive a draw on the nextframe). Gtk.Widget:queue_draw() will also end up requesting a frameon the appropriate frame clock. A widget’s frame clock will not change while the widget ismapped. Reparenting a widget (which implies a temporary unmap) canchange the widget’s frame clock. Unrealized widgets do not have a frame clock.

  • Returns: a GdkFrameClock (or None if widget is unrealized).

  • Since: 3.8


get_scale_factor()

get_scale_factor (self) -> int

Retrieves the internal scale factor that maps from window coordinatesto the actual device pixels. On traditional systems this is 1, onhigh density outputs, it can be a higher value (typically 2). See gdk_window_get_scale_factor().

  • Returns: the scale factor for widget

  • Since: 3.10


add_tick_callback()

add_tick_callback (self, callback:Gtk.TickCallback, user_data=None) -> int

Queues an animation frame update and adds a callback to be calledbefore each frame. Until the tick callback is removed, it will becalled frequently (usually at the frame rate of the output deviceor as quickly as the application can be repainted, whichever isslower). For this reason, is most suitable for handling graphicsthat change every frame or every few frames. The tick callback doesnot automatically imply a relayout or repaint. If you want arepaint or relayout, and aren’t changing widget properties thatwould trigger that (for example, changing the text of a Gtk.Label),then you will have to call Gtk.Widget:queue_resize() orGtk.Widget:queue_draw_area() yourself. gdk_frame_clock_get_frame_time() should generally be used for timingcontinuous animations andgdk_frame_timings_get_predicted_presentation_time() if you aretrying to display isolated frames at particular times. This is a more convenient alternative to connecting directly to the“update” signal of GdkFrameClock, since you don'thave to worry about when a GdkFrameClock is assigned to a widget.

  • Returns: an id for the connection of this callback. Remove the callbackby passing it to Gtk.Widget:remove_tick_callback()

  • Since: 3.8


remove_tick_callback()

remove_tick_callback (self, id:int)

Removes a tick callback previously registered withGtk.Widget:add_tick_callback().

  • Since: 3.8

size_request()

size_request (self) -> requisition:Gtk.Requisition

Gtk.Widget:size_request has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:get_preferred_size() instead. This function is typically used when implementing a Gtk.Containersubclass. Obtains the preferred size of a widget. The containeruses this information to arrange its child widgets and decide whatsize allocations to give them with Gtk.Widget:size_allocate(). You can also call this function from an application, with somecaveats. Most notably, getting a size request requires the widgetto be associated with a screen, because font information may beneeded. Multihead-aware applications should keep this in mind. Also remember that the size request is not necessarily the sizea widget will actually be allocated.


get_child_requisition()

get_child_requisition (self) -> requisition:Gtk.Requisition

Gtk.Widget:get_child_requisition has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:get_preferred_size() instead. This function is only for use in widget implementations. Obtainswidget-&gt;requisition, unless someone has forced a particulargeometry on the widget (e.g. with Gtk.Widget:set_size_request()),in which case it returns that geometry instead of the widget'srequisition. This function differs from Gtk.Widget:size_request() in thatit retrieves the last size request value from widget-&gt;requisition,while Gtk.Widget:size_request() actually calls the "size_request" methodon widget to compute the size request and fill in widget-&gt;requisition,and only then returns widget-&gt;requisition. Because this function does not call the “size_request” method, itcan only be used when you know that widget-&gt;requisition isup-to-date, that is, Gtk.Widget:size_request() has been calledsince the last time a resize was queued. In general, only containerimplementations have this information; applications should useGtk.Widget:size_request().


size_allocate()

size_allocate (self, allocation:Gdk.Rectangle)

This function is only used by Gtk.Container subclasses, to assign a sizeand position to their child widgets. In this function, the allocation may be adjusted. It will be forcedto a 1x1 minimum size, and the adjust_size_allocation virtualmethod on the child will be used to adjust the allocation. Standardadjustments include removing the widget’s margins, and applying thewidget’s “halign” and “valign” properties. For baseline support in containers you need to use Gtk.Widget:size_allocate_with_baseline()instead.


size_allocate_with_baseline()

size_allocate_with_baseline (self, allocation:Gdk.Rectangle, baseline:int)

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. Itwill be forced to a 1x1 minimum size, and theadjust_size_allocation virtual and adjust_baseline_allocationmethods on the child will be used to adjust the allocation andbaseline. Standard adjustments include removing the widget'smargins, and applying the widget’s “halign” and“valign” properties. If the child widget does not have a valign of GTK_ALIGN_BASELINE thebaseline argument is ignored and -1 is used instead.

  • Since: 3.10

add_accelerator()

add_accelerator (self, accel_signal:str, accel_group:Gtk.AccelGroup, accel_key:int, accel_mods:Gdk.ModifierType, accel_flags:Gtk.AccelFlags)

Installs an accelerator for this widget in accel_group that causesaccel_signal to be emitted if the accelerator is activated.The accel_group needs to be added to the widget’s toplevel viaGtk.Window:add_accel_group`()`, and the signal must be of type `G_SIGNAL_ACTION`.Accelerators added through this function are not user changeable duringruntime. If you want to support accelerators that can be changed by theuser, useGtk.AccelMap:add_entry() and Gtk.Widget:set_accel_path() or`Gtk.MenuItem:set_accel_path()` instead.


remove_accelerator()

remove_accelerator (self, accel_group:Gtk.AccelGroup, accel_key:int, accel_mods:Gdk.ModifierType) -> bool

Removes an accelerator from widget, previously installed withGtk.Widget:add_accelerator().

  • Returns: whether an accelerator was installed and could be removed

set_accel_path()

set_accel_path (self, accel_path:str=None, accel_group:Gtk.AccelGroup=None)

Given an accelerator group, accel_group, and an accelerator path,accel_path, sets up an accelerator in accel_group so whenever thekey binding that is defined for accel_path is pressed, widgetwill be activated. This removes any accelerators (for anyaccelerator group) installed by previous calls toGtk.Widget:set_accel_path(). Associating accelerators withpaths allows them to be modified by the user and the modificationsto be saved for future use. (See Gtk.AccelMap:save`()`.) This function is a low level function that would most likelybe used by a menu creation system like `Gtk.UIManager`. If youuse `Gtk.UIManager`, setting up accelerator paths will be doneautomatically. Even when you you aren’t using `Gtk.UIManager`, if you only want toset 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 youpass a static string, you can save some memory by interning it first withg_intern_static_string().


list_accel_closures()

list_accel_closures (self) -> list

Lists the closures used by widget for accelerator group connectionswith Gtk.AccelGroup:connect_by_path`()` orGtk.AccelGroup:connect().The closures can be used to monitor accelerator changes on widget,by connecting to the Gtk.AccelGroup::accel-changed signal of theGtk.AccelGroup of a closure which can be found out with`Gtk.AccelGroup:from_accel_closure()`.

  • Returns: a newly allocated GList of closures.

can_activate_accel()

can_activate_accel (self, signal_id:int) -> bool

Determines whether an accelerator that activates the signalidentified by signal_id can currently be activated.This is done by emitting the “can-activate-accel”signal on widget; if the signal isn’t overridden by ahandler or in a derived widget, then the default check isthat the widget must be sensitive, and the widget and allits ancestors mapped.

  • Returns: True if the accelerator can be activated.

  • Since: 2.4


event()

event (self, event:Gdk.Event) -> bool

Rarely-used function. This function is used to emitthe event signals on a widget (those signals should neverbe 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 ifit were in the event queue. Don’t synthesize expose events; instead,usegdk_window_invalidate_rect()` to invalidate a region of thewindow.

  • Returns: return from the event signal emission (True ifthe event was handled)

activate()

activate (self) -> bool

For widgets that can be “activated” (buttons, menu items, etc.)this function activates them. Activation is what happens when youpress Enter on a widget during key navigation. If widget isn'tactivatable, the function returns FALSE.

  • Returns: True if the widget was activatable

reparent()

reparent (self, new_parent:Gtk.Widget)

Gtk.Widget:reparent has been deprecated since version 3.14 and should not be used in newly-written code. Use Gtk.Container:remove`()` andGtk.Container:add(). Moves a widget from one Gtk.Container to another, handling referencecount issues to avoid destroying the widget.


intersect()

intersect (self, area:Gdk.Rectangle, intersection:Gdk.Rectangle=None) -> bool

Computes the intersection of a widget’s area and area, storingthe intersection in intersection, and returns True if there wasan intersection. intersection may be None if you’re onlyinterested in whether there was an intersection.

  • Returns: True if there was an intersection

is_focus()

is_focus (self) -> bool

Determines if the widget is the focus widget within itstoplevel. (This does not mean that the “has-focus” property isnecessarily set; “has-focus” will only be set if thetoplevel widget additionally has the global input focus.)

  • Returns: True if the widget is the focus widget.

grab_focus()

grab_focus (self)

Causes widget to have the keyboard focus for the Gtk.Window it'sinside. widget must be a focusable widget, such as a Gtk.Entry;something like Gtk.Frame won’t work. More precisely, it must have the GTK_CAN_FOCUS flag set. UseGtk.Widget:set_can_focus() to modify that flag. The widget also needs to be realized and mapped. This is indicated by therelated signals. Grabbing the focus immediately after creating the widgetwill likely fail and cause critical warnings.


grab_default()

grab_default (self)

Causes widget to become the default widget. widget must be able to bea default widget; typically you would ensure this yourselfby calling Gtk.Widget:set_can_default() with a True value.The default widget is activated whenthe user presses Enter in a window. Default widgets must beactivatable, that is, Gtk.Widget:activate() should affect them. Notethat Gtk.Entry widgets require the “activates-default” propertyset to True before they activate the default widget when Enteris pressed and the Gtk.Entry is focused.


set_name()

set_name (self, name:str)

Widgets can be named, which allows you to refer to them from aCSS file. You can apply a style to widgets with a particular namein the CSS file. See the documentation for the CSS syntax (on thesame page as the docs for Gtk.StyleContext). Note that the CSS syntax has certain special characters to delimitand represent elements in a selector (period, #, >, *...), so usingthese will make your widget impossible to match by name. Any combinationof alphanumeric symbols, dashes and underscores will suffice.


get_name()

get_name (self) -> str

Retrieves the name of a widget. See Gtk.Widget:set_name() for thesignificance of widget names.

  • Returns: name of the widget. This string is owned by GTK+ andshould not be modified or freed

set_state()

set_state (self, state:Gtk.StateType)

Gtk.Widget:set_state has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:set_state_flags() instead. This function is for use in widget implementations. Sets the stateof a widget (insensitive, prelighted, etc.) Usually you should setthe state using wrapper functions such as Gtk.Widget:set_sensitive().


set_sensitive()

set_sensitive (self, sensitive:bool)

Sets the sensitivity of a widget. A widget is sensitive if the usercan interact with it. Insensitive widgets are “grayed out” and theuser can’t interact with them. Insensitive widgets are known as“inactive”, “disabled”, or “ghosted” in some other toolkits.


set_parent()

set_parent (self, parent:Gtk.Widget)

This function is useful only when implementing subclasses ofGtk.Container.Sets the container as the parent of widget, and takes care ofsome details such as updating the state and style of the childto reflect its new location. The opposite function isGtk.Widget:unparent().


set_parent_window()

set_parent_window (self, parent_window:Gdk.Window)

Sets a non default parent window for widget. For Gtk.Window classes, setting a parent_window effects whetherthe window is a toplevel window or can be embedded into otherwidgets. For Gtk.Window classes, this needs to be called before thewindow is realized.


get_parent_window()

get_parent_window (self) -> Gdk.Window

Gets widget’s parent window.

  • Returns: the parent window of widget.

set_events()

set_events (self, events:int)

Sets the event mask (see GdkEventMask) for a widget. The eventmask determines which events a widget will receive. Keep in mindthat different widgets have different default event masks, and bychanging the event mask you may disrupt a widget’s functionality,so be careful. This function must be called while a widget isunrealized. Consider Gtk.Widget:add_events() for widgets that arealready realized, or if you want to preserve the existing eventmask. This function can’t be used with widgets that have no window.(See Gtk.Widget:get_has_window()). To get events on those widgets,place them inside a Gtk.EventBox and receive events on the eventbox.


get_events()

get_events (self) -> int

Returns the event mask (see GdkEventMask) for the widget. These are theevents that the widget will receive. Note: Internally, the widget event mask will be the logical OR of the eventmask set through Gtk.Widget:set_events() or Gtk.Widget:add_events(), and theevent mask necessary to cater for every Gtk.EventController created for thewidget.

  • Returns: event mask for widget

add_events()

add_events (self, events:int)

Adds the events in the bitfield events to the event mask forwidget. See Gtk.Widget:set_events() and theinput handling overview for details.


set_device_events()

set_device_events (self, device:Gdk.Device, events:Gdk.EventMask)

Sets the device event mask (see GdkEventMask) for a widget. The eventmask determines which events a widget will receive from device. Keepin mind that different widgets have different default event masks, and bychanging the event mask you may disrupt a widget’s functionality,so be careful. This function must be called while a widget isunrealized. Consider Gtk.Widget:add_device_events() for widgets that arealready realized, or if you want to preserve the existing eventmask. This function can’t be used with windowless widgets (which returnFALSE from Gtk.Widget:get_has_window());to get events on those widgets, place them inside a Gtk.EventBoxand receive events on the event box.

  • Since: 3.0

get_device_events()

get_device_events (self, device:Gdk.Device) -> Gdk.EventMask

Returns the events mask for the widget corresponding to an specific device. Theseare the events that the widget will receive when device operates on it.

  • Returns: device event mask for widget

  • Since: 3.0


add_device_events()

add_device_events (self, device:Gdk.Device, events:Gdk.EventMask)

Adds the device events in the bitfield events to the event mask forwidget. See Gtk.Widget:set_device_events() for details.

  • Since: 3.0

set_device_enabled()

set_device_enabled (self, device:Gdk.Device, enabled:bool)

Enables or disables a GdkDevice to interact with widgetand all its children. It does so by descending through the GdkWindow hierarchyand enabling the same mask that is has for core events(i.e. the one that gdk_window_get_events() returns).

  • Since: 3.0

get_device_enabled()

get_device_enabled (self, device:Gdk.Device) -> bool

Returns whether device can interact with widget and itschildren. See Gtk.Widget:set_device_enabled().

  • Returns: True is deviceis enabled for widget

  • Since: 3.0


get_toplevel()

get_toplevel (self) -> Gtk.Widget

This function returns the topmost widget in the container hierarchywidget is a part of. If widget has no parent widgets, it will bereturned as the topmost widget. No reference will be added to thereturned 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 widget wasn’t inside a toplevel window, and if thewindow was inside a `Gtk.Window-derivedwidget which was in turninside the toplevelGtk.Window. While the second case mayseem unlikely, it actually happens when aGtk.Plugis embeddedinside aGtk.Socketwithin the same application. To reliably find the toplevelGtk.Window, useGtk.Widget:get_toplevel()and callGtk.Widget:is_toplevel()on the result.Gtk.Widget` *toplevel = Gtk.Widget:get_toplevel (widget); if (Gtk.Widget:is_toplevel (toplevel)) { // Perform action on toplevel. }

  • Returns: the topmost ancestor of widget, or widgetitselfif there’s no ancestor.

get_ancestor()

get_ancestor (self, widget_type:GType) -> Gtk.Widget or None

Gets the first ancestor of widget with type widget_type. For example,Gtk.Widget:get_ancestor (widget, GTK_TYPE_BOX) getsthe first Gtk.Box that’s an ancestor of widget. No reference will beadded to the returned widget; it should not be unreferenced. See noteabout checking for a toplevel Gtk.Window in the docs forGtk.Widget:get_toplevel(). Note that unlike Gtk.Widget:is_ancestor(), Gtk.Widget:get_ancestor()considers widget to be an ancestor of itself.

  • Returns: the ancestor widget, or None if not found.

get_visual()

get_visual (self) -> Gdk.Visual

Gets the visual that will be used to render widget.

  • Returns: the visual for widget.

set_visual()

set_visual (self, visual:Gdk.Visual=None)

Sets the visual that should be used for by widget and its children forcreating GdkWindows. The visual must be on the same GdkScreen asreturned by Gtk.Widget:get_screen(), so handling the“screen-changed” signal is necessary. Setting a new visual will not cause widget to recreate its windows,so you should call this function before widget is realized.


get_pointer()

get_pointer (self) -> x:int, y:int

Gtk.Widget:get_pointer has been deprecated since version 3.4 and should not be used in newly-written code. Use gdk_window_get_device_position() instead. Obtains the location of the mouse pointer in widget coordinates.Widget coordinates are a bit odd; for historical reasons, they aredefined as widget-&gt;window coordinates for widgets that return True forGtk.Widget:get_has_window(); and are relative to widget-&gt;allocation.x,widget-&gt;allocation.y otherwise.


is_ancestor()

is_ancestor (self, ancestor:Gtk.Widget) -> bool

Determines whether widget is somewhere inside ancestor, possibly withintermediate containers.

  • Returns: True if ancestorcontains widgetas a child,grandchild, great grandchild, etc.

hide_on_delete()

hide_on_delete (self) -> bool

Utility function; intended to be connected to the “delete-event”signal on a Gtk.Window. The function calls Gtk.Widget:hide() on itsargument, then returns True. If connected to ::delete-event, theresult is that clicking the close button for a window (on thewindow frame, top right corner usually) will hide but not destroythe window. By default, GTK+ destroys windows when ::delete-eventis received.

  • Returns: True

set_style()

set_style (self, style:Gtk.Style=None)

Gtk.Widget:set_style has been deprecated since version 3.0 and should not be used in newly-written code. Use `Gtk.StyleContextinstead Used to set theGtk.Stylefor a widget (widget->style`). SinceGTK 3, this function does nothing, the passed in style is ignored.


ensure_style()

ensure_style (self)

Gtk.Widget:ensure_style has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.StyleContext instead Ensures that widget has a style (widget-&gt;style). Not a very useful function; most of the time, if youwant the style, the widget is realized, and realizedwidgets are guaranteed to have a style already.


get_style()

get_style (self) -> Gtk.Style

Gtk.Widget:get_style has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.StyleContext instead Simply an accessor function that returns widget-&gt;style.

  • Returns: the widget’s Gtk.Style.

reset_rc_styles()

reset_rc_styles (self)

Gtk.Widget:reset_rc_styles has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.StyleContext instead, and Gtk.Widget:reset_style() Reset the styles of widget and all descendents, so whenthey are looked up again, they get the correct valuesfor the currently loaded RC file settings. This function is not useful for applications.


get_default_style()

get_default_style () -> Gtk.Style

Gtk.Widget:get_default_style has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.StyleContext instead, and `Gtk.CssProvider:get_default()to obtain aGtk.StyleProvider` with the default widget style information. Returns the default style used by all widgets initially.

  • Returns: the default style. This Gtk.Styleobject is owned by GTK+ and should not be modified or freed.

set_direction()

set_direction (self, dir:Gtk.TextDirection)

Sets the reading direction on a particular widget. This directioncontrols the primary direction for widgets containing text,and also the direction in which the children of a container arepacked. The ability to set the direction is present in orderso that correct localization into languages with right-to-leftreading directions can be done. Generally, applications willlet the default reading direction present, except for containerswhere the containers are arranged in an order that is explicitlyvisual rather than logical (such as buttons for text justification). If the direction is set to GTK_TEXT_DIR_NONE, then the valueset by Gtk.Widget:set_default_direction() will be used.


get_direction()

get_direction (self) -> Gtk.TextDirection

Gets the reading direction for a particular widget. SeeGtk.Widget:set_direction().

  • Returns: the reading direction for the widget.

set_default_direction()

set_default_direction (dir:Gtk.TextDirection)

Sets the default reading direction for widgets where thedirection has not been explicitly set by Gtk.Widget:set_direction().


get_default_direction()

get_default_direction () -> Gtk.TextDirection

Obtains the current default reading direction. SeeGtk.Widget:set_default_direction().

  • Returns: the current default direction.

shape_combine_region()

shape_combine_region (self, region:cairo.Region=None)

Sets a shape for this widget’s GDK window. This allows fortransparent windows etc., see gdk_window_shape_combine_region()for more information.

  • Since: 3.0

input_shape_combine_region()

input_shape_combine_region (self, region:cairo.Region=None)

Sets an input shape for this widget’s GDK window. This allows forwindows which react to mouse click in a nonrectangular region, seegdk_window_input_shape_combine_region() for more information.

  • Since: 3.0

path()

path (self) -> path_length:int, path:str, path_reversed:str

Gtk.Widget:path has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:get_path() instead Obtains the full path to widget. The path is simply the name of awidget and all its parents in the container hierarchy, separated byperiods. The name of a widget comes fromGtk.Widget:get_name(). Paths are used to apply styles to a widgetin gtkrc configuration files. Widget names are the type of thewidget by default (e.g. “Gtk.Button”) or can be set to anapplication-specific value with Gtk.Widget:set_name(). By settingthe name of a widget, you allow users or theme authors to applystyles to that specific widget in their gtkrcfile. path_reversed_p fills in the path in reverse order,i.e. starting with widget’s name instead of starting with the nameof widget’s outermost ancestor.


class_path()

class_path (self) -> path_length:int, path:str, path_reversed:str

Gtk.Widget:class_path has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:get_path() instead Same as Gtk.Widget:path(), but always uses the name of a widget’s type,never uses a custom name set with Gtk.Widget:set_name().


get_composite_name()

get_composite_name (self) -> str

Gtk.Widget:get_composite_name has been deprecated since version 3.10 and should not be used in newly-written code. Use Gtk.Widget:class_set_template(), or don’t use this API at all. Obtains the composite name of a widget.

  • Returns: the composite name of widget, or None if widgetis nota composite child. The string should be freed when it is nolonger needed.

override_background_color()

override_background_color (self, state:Gtk.StateFlags, color:Gdk.RGBA=None)

Gtk.Widget:override_background_color has been deprecated since version 3.16 and should not be used in newly-written code. 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 the “draw” signal, and use Cairo to draw a specific color, regardless of the CSS style. Sets the background color to use for a widget. All other style values are left untouched.See Gtk.Widget:override_color().

  • Since: 3.0

override_color()

override_color (self, state:Gtk.StateFlags, color:Gdk.RGBA=None)

Gtk.Widget:override_color has been deprecated since version 3.16 and should not be used in newly-written code. Use a custom style provider and style classes instead 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 acontainer does not affect its children. Note that some widgets thatyou may not think of as containers, for instance Gtk.Buttons,are actually containers. This API is mostly meant as a quick way for applications tochange a widget appearance. If you are developing a widgetslibrary and intend this change to be themeable, it is betterdone by setting meaningful CSS classes and regions in yourwidget/container implementation through Gtk.StyleContext:add_class`()`andGtk.StyleContext:add_region(). This way, your widget library can install a `Gtk.CssProviderwiththeGTK_STYLE_PROVIDER_PRIORITY_FALLBACKpriority in orderto provide a default styling for those widgets that need so, andthis theming may fully overridden by the user’s theme. Note that for complex widgets this may bring in undesiredresults (such as uniform background color everywhere), inthese cases it is better to fully style such widgets through aGtk.CssProviderwith theGTK_STYLE_PROVIDER_PRIORITY_APPLICATION`priority.

  • Since: 3.0

override_font()

override_font (self, font_desc:Pango.FontDescription=None)

Gtk.Widget:override_font has been deprecated since version 3.16 and should not be used in newly-written code. 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. Sets the font to use for a widget. All other style values areleft untouched. See Gtk.Widget:override_color().

  • Since: 3.0

override_symbolic_color()

override_symbolic_color (self, name:str, color:Gdk.RGBA=None)

Gtk.Widget:override_symbolic_color has been deprecated since version 3.16 and should not be used in newly-written code. 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. Sets a symbolic color for a widget. All other style values are left untouched.See Gtk.Widget:override_color() for overriding the foregroundor background color.

  • Since: 3.0

override_cursor()

override_cursor (self, cursor:Gdk.RGBA=None, secondary_cursor:Gdk.RGBA=None)

Gtk.Widget:override_cursor has been deprecated since version 3.16 and should not be used in newly-written code. 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. Sets the cursor color to use in a widget, overriding thecursor-color and secondary-cursor-colorstyle properties. All other style values are left untouched.See also Gtk.Widget:modify_style(). Note that the underlying properties have the GdkColor type,so the alpha value in primary and secondary will be ignored.

  • Since: 3.0

modify_style()

modify_style (self, style:Gtk.RcStyle)

Gtk.Widget:modify_style has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.StyleContext with a custom Gtk.StyleProvider instead Modifies style values on the widget. Modifications made using this technique take precedence overstyle values set via an RC file, however, they will be overriddenif a style is explicitly set on the widget using Gtk.Widget:set_style().The Gtk.RcStyle is designed so each field can either beset or unset, so it is possible, using this function, to modify somestyle values and leave the others unchanged. Note that modifications made with this function are not cumulativewith previous calls to Gtk.Widget:modify_style() or with suchfunctions as Gtk.Widget:modify_fg(). If you wish to retainprevious values, you must first call Gtk.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 call Gtk.Widget:modify_style(), subsequent callsto such functions Gtk.Widget:modify_fg() will have a cumulativeeffect with the initial modifications.


get_modifier_style()

get_modifier_style (self) -> Gtk.RcStyle

Gtk.Widget:get_modifier_style has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.StyleContext with a custom Gtk.StyleProvider instead Returns the current modifier style for the widget. (As set byGtk.Widget:modify_style().) If no style has previously set, a newGtk.RcStyle will be created with all values unset, and set as themodifier style for the widget. If you make changes to this rcstyle, you must call Gtk.Widget:modify_style(), passing in thereturned rc style, to make sure that your changes take effect. Caution: passing the style back to Gtk.Widget:modify_style() willnormally end up destroying it, because Gtk.Widget:modify_style() copiesthe passed-in style and sets the copy as the new modifier style,thus dropping any reference to the old modifier style. Add a referenceto the modifier style if you want to keep it alive.

  • Returns: the modifier style for the widget.This rc style is owned by the widget. If you want to keep apointer to value this around, you must add a refcount usingg_object_ref().

modify_fg()

modify_fg (self, state:Gtk.StateType, color:Gdk.Color=None)

Gtk.Widget:modify_fg has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:override_color() instead Sets the foreground color for a widget in a particular state. All other style values are left untouched.See also Gtk.Widget:modify_style().


modify_bg()

modify_bg (self, state:Gtk.StateType, color:Gdk.Color=None)

Gtk.Widget:modify_bg has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:override_background_color() instead 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_WINDOWflag set) draw on their parent container’s window and thus maynot draw any background themselves. This is the case for e.g.Gtk.Label. To modify the background of such widgets, you have to set thebackground color on their parent; if you want to set the backgroundof a rectangular area around a label, try placing the label ina Gtk.EventBox widget and setting the background color on that.


modify_text()

modify_text (self, state:Gtk.StateType, color:Gdk.Color=None)

Gtk.Widget:modify_text has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:override_color() instead 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 thebase color (see Gtk.Widget:modify_base()) for widgets suchas Gtk.Entry and Gtk.TextView.See also Gtk.Widget:modify_style().


modify_base()

modify_base (self, state:Gtk.StateType, color:Gdk.Color=None)

Gtk.Widget:modify_base has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:override_background_color() instead Sets the base color for a widget in a particular state.All other style values are left untouched. The base coloris the background color used along with the text color(see Gtk.Widget:modify_text()) for widgets such as Gtk.Entryand Gtk.TextView. See also Gtk.Widget:modify_style(). Note that “no window” widgets (which have the GTK_NO_WINDOWflag set) draw on their parent container’s window and thus maynot draw any background themselves. This is the case for e.g.Gtk.Label. To modify the background of such widgets, you have to set thebase color on their parent; if you want to set the backgroundof a rectangular area around a label, try placing the label ina Gtk.EventBox widget and setting the base color on that.


modify_font()

modify_font (self, font_desc:Pango.FontDescription=None)

Gtk.Widget:modify_font has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:override_font() instead Sets the font to use for a widget. All other style values are left untouched.See also Gtk.Widget:modify_style().


modify_cursor()

modify_cursor (self, primary:Gdk.Color=None, secondary:Gdk.Color=None)

Gtk.Widget:modify_cursor has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:override_cursor() instead. Sets the cursor color to use in a widget, overriding the Gtk.Widgetcursor-color and secondary-cursor-colorstyle properties. All other style values are left untouched.See also Gtk.Widget:modify_style().

  • Since: 2.12

create_pango_context()

create_pango_context (self) -> Pango.Context

Creates a new PangoContext with the appropriate font map,font options, font description, and base direction for drawingtext for this widget. See also Gtk.Widget:get_pango_context().

  • Returns: the new PangoContext.

get_pango_context()

get_pango_context (self) -> Pango.Context

Gets a PangoContext with the appropriate font map, font description,and base direction for this widget. Unlike the context returnedby Gtk.Widget:create_pango_context(), this context is owned bythe widget (it can be used until the screen for the widget changesor the widget is removed from its toplevel), and will be updated tomatch any changes to the widget’s attributes. This can be trackedby using the “screen-changed” signal on the widget.

  • Returns: the PangoContext for the widget.

set_font_options()

set_font_options (self, options:cairo.FontOptions=None)

Sets the cairo_font_options_t used for Pango rendering in this widget.When not set, the default font options for the GdkScreen will be used.

  • Since: 3.18

get_font_options()

get_font_options (self) -> cairo.FontOptions or None

Returns the cairo_font_options_t used for Pango rendering. When not set,the defaults font options for the GdkScreen will be used.

  • Returns: the cairo_font_options_t or None if not set.

  • Since: 3.18


set_font_map()

set_font_map (self, font_map:Pango.FontMap=None)

Sets the font map to use for Pango rendering. When not set, the widgetwill inherit the font map from its parent.

  • Since: 3.18

get_font_map()

get_font_map (self) -> Pango.FontMap or None

Gets the font map that has been set with Gtk.Widget:set_font_map().

  • Returns: A PangoFontMap, or None.

  • Since: 3.18


create_pango_layout()

create_pango_layout (self, text:str=None) -> Pango.Layout

Creates a new PangoLayout with the appropriate font map,font description, and base direction for drawing text forthis widget. If you keep a PangoLayout created in this way around, you needto re-create it when the widget PangoContext is replaced.This can be tracked by using the “screen-changed” signalon the widget.

  • Returns: the new PangoLayout.

render_icon()

render_icon (self, stock_id:str, size:int, detail:str=None) -> GdkPixbuf.Pixbuf

Gtk.Widget:render_icon has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:render_icon_pixbuf() instead. A convenience function that uses the theme settings for widgetto look up stock_id and render it to a pixbuf. stock_id shouldbe a stock icon ID such as GTK_STOCK_OPEN or GTK_STOCK_OK. sizeshould be a size such as GTK_ICON_SIZE_MENU. detail should be astring that identifies the widget or code doing the rendering, sothat theme engines can special-case rendering for that widget orcode. The pixels in the returned GdkPixbuf are shared with the rest ofthe application and should not be modified. The pixbuf should befreed after use with g_object_unref().

  • Returns: a new pixbuf, or None if thestock ID wasn’t known.

render_icon_pixbuf()

render_icon_pixbuf (self, stock_id:str, size:int) -> GdkPixbuf.Pixbuf or None

Gtk.Widget:render_icon_pixbuf has been deprecated since version 3.10 and should not be used in newly-written code. Use `Gtk.IconTheme:load_icon()instead. A convenience function that uses the theme engine and stylesettings forwidgetto look upstock_idand render it toa pixbuf.stock_idshould be a stock icon ID such asGTK_STOCK_OPEN or GTK_STOCK_OK.sizeshould be a sizesuch as GTK_ICON_SIZE_MENU. The pixels in the returned GdkPixbuf are shared with the rest ofthe application and should not be modified. The pixbuf should be freedafter use withg_object_unref()`.

  • Returns: a new pixbuf, or None if thestock ID wasn’t known.

  • Since: 3.0


pop_composite_child()

pop_composite_child ()

push_composite_child()

push_composite_child ()

queue_draw_area()

queue_draw_area (self, x:int, y:int, width:int, height:int)

Convenience function that calls Gtk.Widget:queue_draw_region() onthe region created from the given coordinates. The region here is specified in widget coordinates.Widget coordinates are a bit odd; for historical reasons, they aredefined as widget-&gt;window coordinates for widgets that return True forGtk.Widget:get_has_window(), and are relative to widget-&gt;allocation.x,widget-&gt;allocation.y otherwise. width or height may be 0, in this case this function doesnothing. Negative values for width and height are not allowed.


queue_draw_region()

queue_draw_region (self, region:cairo.Region)

Invalidates the area of widget defined by region by callinggdk_window_invalidate_region() on the widget’s window and all itschild windows. Once the main loop becomes idle (after the currentbatch of events has been processed, roughly), the window willreceive expose events for the union of all regions that have beeninvalidated. Normally you would only use this function in widgetimplementations. You might also use it to schedule a redraw of aGtk.DrawingArea or some portion thereof.

  • Since: 3.0

set_app_paintable()

set_app_paintable (self, app_paintable:bool)

Sets whether the application intends to draw on the widget inan “draw” handler. This is a hint to the widget and does not affect the behavior ofthe GTK+ core; many widgets ignore this flag entirely. For widgetsthat do pay attention to the flag, such as Gtk.EventBox and Gtk.Window,the effect is to suppress default themed drawing of the widget'sbackground. (Children of the widget will still be drawn.) The applicationis then entirely responsible for drawing the widget background. Note that the background is still drawn when the widget is mapped.


set_double_buffered()

set_double_buffered (self, double_buffered:bool)

Gtk.Widget:set_double_buffered has been deprecated since version 3.14 and should not be used in newly-written code. This function does not work under non-X11 backends or withnon-native windows.It should not be used in newly written code. Widgets are double buffered by default; you can use this functionto turn off the buffering. “Double buffered” simply means thatgdk_window_begin_paint_region() and gdk_window_end_paint() are calledautomatically around expose events sent to thewidget. gdk_window_begin_paint_region() diverts all drawing to a widget'swindow to an offscreen buffer, and gdk_window_end_paint() draws thebuffer to the screen. The result is that users see the windowupdate in one smooth step, and don’t see individual graphicsprimitives being rendered. In very simple terms, double buffered widgets don’t flicker,so you would only use this function to turn off double bufferingif you had special needs and really knew what you were doing. Note: if you turn off double-buffering, you have to handleexpose events, since even the clearing to the background color orpixmap will not happen automatically (as it is done ingdk_window_begin_paint_region()). In 3.10 GTK and GDK have been restructured for translucent drawing. Sincethen expose events for double-buffered widgets are culled into a singleevent to the toplevel GDK window. If you now unset double buffering, youwill cause a separate rendering pass for every widget. This will likelycause rendering problems - in particular related to stacking - and usuallyincreases rendering times significantly.


set_redraw_on_allocate()

set_redraw_on_allocate (self, redraw_on_allocate:bool)

Sets whether the entire widget is queued for drawing when its sizeallocation changes. By default, this setting is True andthe entire widget is redrawn on every size change. If your widgetleaves the upper left unchanged when made bigger, turning thissetting off will improve performance. Note that for widgets where Gtk.Widget:get_has_window() is FALSEsetting this flag to FALSE turns off all allocation on resizing:the widget will not even redraw if its position changes; this is toallow containers that don’t draw anything to avoid excessinvalidations. If you set this flag on a widget with no window thatdoes draw on widget-&gt;window, you areresponsible for invalidating both the old and new allocation of thewidget when the widget is moved and responsible for invalidatingregions newly when the widget increases size.


set_composite_name()

set_composite_name (self, name:str)

Gtk.Widget:set_composite_name has been deprecated since version 3.10 and should not be used in newly-written code. Use Gtk.Widget:class_set_template(), or don’t use this API at all. Sets a widgets composite name. The widget must bea composite child of its parent; see Gtk.Widget:push_composite_child().


mnemonic_activate()

mnemonic_activate (self, group_cycling:bool) -> bool

Emits the “mnemonic-activate” signal. The default handler for this signal activates the widget ifgroup_cycling is FALSE, and just grabs the focus if group_cyclingis True.

  • Returns: True if the signal has been handled

region_intersect()

region_intersect (self, region:cairo.Region) -> cairo.Region

Gtk.Widget:region_intersect has been deprecated since version 3.14 and should not be used in newly-written code. Use Gtk.Widget:get_allocation() and cairo_region_intersect_rectangle() to get the same behavior. Computes the intersection of a widget’s area and region, returningthe intersection. The result may be empty, use cairo_region_is_empty() tocheck.

  • Returns: A newly allocated region holding the intersection of widgetand region.

send_expose()

send_expose (self, event:Gdk.Event) -> int

Very rarely-used function. This function is used to emitan expose event on a widget. This function is not normally useddirectly. The only time it is used is when propagating an exposeevent to a windowless child widget (Gtk.Widget:get_has_window() is FALSE),and that is normally done using `Gtk.Container:propagate_draw(). If you want to force an area of a window to be redrawn,usegdk_window_invalidate_rect()orgdk_window_invalidate_region().To cause the redraw to be done immediately, follow that callwith a call togdk_window_process_updates()`.

  • Returns: return from the event signal emission (True ifthe event was handled)

send_focus_change()

send_focus_change (self, event:Gdk.Event) -> bool

Sends the focus change event to widget This function is not meant to be used by applications. The only time itshould be used is when it is necessary for a Gtk.Widget to assign focusto a widget that is semantically owned by the first widget even thoughit’s not a direct child - for instance, a search entry in a floatingwindow similar to the quick search in Gtk.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 != None) g_object_ref (fevent->focus_change.window); Gtk.Widget:send_focus_change (widget, fevent); gdk_event_free (event);

  • Returns: the return value from the event signal emission: Trueif the event was handled, and FALSE otherwise

  • Since: 2.20


style_get_property()

style_get_property (self, property_name:str, value:GObject.Value)

Gets the value of a style property of widget.


style_attach()

style_attach (self)

Gtk.Widget:style_attach has been deprecated since version 3.0 and should not be used in newly-written code. This step is unnecessary with `Gtk.StyleContext. This function attaches the widget’sGtk.Styleto the widget'sGdkWindow. It is a replacement for widget-&gt;style =Gtk.Style:attach(widget-&gt;style, widget-&gt;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(finallyGtk.Widget)` would attach the style itself.

  • Since: 2.20

get_accessible()

get_accessible (self) -> Atk.Object

Returns the accessible object that describes the widget to anassistive technology. If accessibility support is not available, this AtkObjectinstance may be a no-op. Likewise, if no class-specific AtkObjectimplementation is available for the widget instance in question,it will inherit an AtkObject implementation from the first ancestorclass for which such an implementation is defined. The documentation of theATKlibrary contains more information about accessible objects and their uses.

  • Returns: the AtkObject associated with widget.

child_focus()

child_focus (self, direction:Gtk.DirectionType) -> bool

This function is used by custom widget implementations; if you'rewriting an app, you’d use Gtk.Widget:grab_focus() to move the focusto a particular widget, and `Gtk.Container:set_focus_chain()tochange the focus tab order. So you may want to investigate thosefunctions instead. Gtk.Widget:child_focus() is called by containers as the user movesaround the window using keyboard shortcuts.directionindicateswhat kind of motion is taking place (up, down, left, right, tabforward, tab backward).Gtk.Widget:child_focus()emits the“focus” signal; widgets override the default handlerfor this signal in order to implement appropriate focus behavior. The default ::focus handler for a widget should returnTrueifmoving indirectionleft the focus on a focusable location insidethat widget, andFALSEif moving indirectionmoved the focusoutside the widget. If returningTrue, widgets normallycallGtk.Widget:grab_focus()to place the focus accordingly;if returningFALSE`, they don’t modify the current focus location.

  • Returns: True if focus ended up inside widget

child_notify()

child_notify (self, child_property:str)

Emits a “child-notify” signal for thechild property child_propertyon widget. This is the analogue of g_object_notify() for child properties. Also see `Gtk.Container:child_notify()`.


freeze_child_notify()

freeze_child_notify (self)

Stops emission of “child-notify” signals on widget. Thesignals are queued until Gtk.Widget:thaw_child_notify() is calledon widget. This is the analogue of g_object_freeze_notify() for child properties.


get_child_visible()

get_child_visible (self) -> bool

Gets the value set with Gtk.Widget:set_child_visible().If you feel a need to use this function, your code probablyneeds reorganization. This function is only useful for container implementations andnever should be called by an application.

  • Returns: True if the widget is mapped with the parent.

get_parent()

get_parent (self) -> Gtk.Widget or None

Returns the parent container of widget.

  • Returns: the parent container of widget, or None.

get_settings()

get_settings (self) -> Gtk.Settings

Gets the settings object holding the settings used for this widget. Note that this function can only be called when the Gtk.Widgetis attached to a toplevel, since the settings object is specificto a particular GdkScreen.

  • Returns: the relevant Gtk.Settings object.

get_clipboard()

get_clipboard (self, selection:Gdk.Atom) -> Gtk.Clipboard

Returns the clipboard object for the given selection tobe used with widget. widget must have a GdkDisplayassociated with it, so must be attached to a toplevelwindow.

  • Returns: the appropriate clipboard object. If noclipboard already exists, a new one willbe created. Once a clipboard object hasbeen created, it is persistent for all time.

  • Since: 2.2


get_display()

get_display (self) -> Gdk.Display

Get the GdkDisplay for the toplevel window associated withthis widget. This function can only be called after the widgethas been added to a widget hierarchy with a Gtk.Window at the top. In general, you should only create display specificresources when a widget has been realized, and you shouldfree those resources when the widget is unrealized.

  • Returns: the GdkDisplay for the toplevel for this widget.

  • Since: 2.2


get_root_window()

get_root_window (self) -> Gdk.Window

Gtk.Widget:get_root_window has been deprecated since version 3.12 and should not be used in newly-written code. Use gdk_screen_get_root_window() instead Get the root window where this widget is located. This function canonly be called after the widget has been added to a widgethierarchy with Gtk.Window at the top. The root window is useful for such purposes as creating a popupGdkWindow associated with the window. In general, you should onlycreate display specific resources when a widget has been realized,and you should free those resources when the widget is unrealized.

  • Returns: the GdkWindow root window for the toplevel for this widget.

  • Since: 2.2


get_screen()

get_screen (self) -> Gdk.Screen

Get the GdkScreen from the toplevel window associated withthis widget. This function can only be called after the widgethas been added to a widget hierarchy with a Gtk.Windowat the top. In general, you should only create screen specificresources when a widget has been realized, and you shouldfree those resources when the widget is unrealized.

  • Returns: the GdkScreen for the toplevel for this widget.

  • Since: 2.2


has_screen()

has_screen (self) -> bool

Checks whether there is a GdkScreen is associated withthis widget. All toplevel widgets have an associatedscreen, and all widgets added into a hierarchy with a toplevelwindow at the top.

  • Returns: True if there is a GdkScreen associatedwith the widget.

  • Since: 2.2


get_size_request()

get_size_request (self) -> width:int, height:int

Gets the size request that was explicitly set for the widget usingGtk.Widget:set_size_request(). A value of -1 stored in width orheight indicates that that dimension has not been set explicitlyand the natural requisition of the widget will be used instead. SeeGtk.Widget:set_size_request(). To get the size a widget willactually request, call Gtk.Widget:get_preferred_size() instead ofthis function.


set_child_visible()

set_child_visible (self, is_visible:bool)

Sets whether widget should be mapped along with its when its parentis mapped and widget has been shown with Gtk.Widget:show(). The child visibility can be set for widget before it is added toa container with Gtk.Widget:set_parent(), to avoid mappingchildren unnecessary before immediately unmapping them. Howeverit will be reset to its default state of True when the widgetis removed from a container. Note that changing the child visibility of a widget does notqueue a resize on the widget. Most of the time, the size ofa widget is computed from all visible children, whether ornot they are mapped. If this is not the case, the containercan queue a resize itself. This function is only useful for container implementations andnever should be called by an application.


set_size_request()

set_size_request (self, width:int, height:int)

Sets the minimum size of a widget; that is, the widget’s sizerequest 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 fortoplevel windows than this function; setting the default size willstill allow users to shrink the window. Setting the size requestwill force them to leave the window at least as large as the sizerequest. 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 actioncan all change the appropriate size for a given widget. So, it'sbasically impossible to hardcode a size that will always becorrect. The size request of a widget is the smallest size a widget canaccept while still functioning well and drawing itself correctly.However in some strange cases a widget may be allocated less thanits requested size, and in many cases a widget may be allocated morespace than it requested. If the size request in a given direction is -1 (unset), thenthe “natural” size request of the widget will be used instead. The size request set here does not include any margin from theGtk.Widget properties margin-left, margin-right, margin-top, andmargin-bottom, but it does include pretty much all other paddingor border properties set by any subclass of Gtk.Widget.


thaw_child_notify()

thaw_child_notify (self)

Reverts the effect of a previous call to Gtk.Widget:freeze_child_notify().This causes all queued “child-notify” signals on widget to beemitted.


set_no_show_all()

set_no_show_all (self, no_show_all:bool)

Sets the “no-show-all” property, which determines whethercalls to Gtk.Widget:show_all() will affect this widget. This is mostly for use in constructing widget hierarchies with externallycontrolled visibility, see Gtk.UIManager.

  • Since: 2.4

get_no_show_all()

get_no_show_all (self) -> bool

Returns the current value of the “no-show-all” property,which determines whether calls to Gtk.Widget:show_all()will affect this widget.

  • Returns: the current value of the “no-show-all” property.

  • Since: 2.4


list_mnemonic_labels()

list_mnemonic_labels (self) -> list

Returns a newly allocated list of the widgets, normally labels, forwhich 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 youwant to iterate through the list and perform actions involvingcallbacks that might destroy the widgets, youmust callg_list_foreach (result,(GFunc)g_object_ref, None)` first, and then unref all thewidgets afterwards.

  • Returns: the list ofmnemonic labels; free this listwith g_list_free() when you are done with it.

  • Since: 2.4


add_mnemonic_label()

add_mnemonic_label (self, label:Gtk.Widget)

Adds a widget to the list of mnemonic labels forthis widget. (See Gtk.Widget:list_mnemonic_labels()). Note thelist of mnemonic labels for the widget is cleared when thewidget is destroyed, so the caller must make sure to updateits internal state at this point as well, by using a connectionto the “destroy” signal or a weak notifier.

  • Since: 2.4

remove_mnemonic_label()

remove_mnemonic_label (self, label:Gtk.Widget)

Removes a widget from the list of mnemonic labels forthis widget. (See Gtk.Widget:list_mnemonic_labels()). The widgetmust have previously been added to the list withGtk.Widget:add_mnemonic_label().

  • Since: 2.4

is_composited()

is_composited (self) -> bool

Whether widget can rely on having its alpha channeldrawn correctly. On X11 this function returns whether acompositing manager is running for widget’s screen. Please note that the semantics of this call will changein the future if used on a widget that has a compositedwindow in its hierarchy (as set by gdk_window_set_composited()).

  • Returns: True if the widget can rely on its alphachannel being drawn correctly.

  • Since: 2.10


error_bell()

error_bell (self)

Notifies the user about an input-related error on this widget.If the “gtk-error-bell” setting is True, it callsgdk_window_beep(), otherwise it does nothing. Note that the effect of gdk_window_beep() can be configured in manyways, depending on the windowing backend and the desktop environmentor window manager that is used.

  • Since: 2.12

keynav_failed()

keynav_failed (self, direction:Gtk.DirectionType) -> bool

This function should be called whenever keyboard navigation withina single widget hits a boundary. The function emits the“keynav-failed” signal on the widget and its returnvalue 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 keyboardnavigation is OK and/or there is nowhere we can/should move thefocus to. When FALSE is returned, the caller should continue with keyboardnavigation outside the widget, e.g. by callingGtk.Widget:child_focus() on the widget’s toplevel. The default ::keynav-failed handler returns True forGTK_DIR_TAB_FORWARD and GTK_DIR_TAB_BACKWARD. For the othervalues of Gtk.DirectionType it returns FALSE. Whenever the default handler returns True, it also callsGtk.Widget:error_bell() to notify the user of the failed keyboardnavigation. 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 theentire row with the cursor keys, as e.g. known from user interfacesthat require entering license keys.

  • Returns: True if stopping keyboard navigation is fine, FALSEif the emitting widget should try to handle the keyboardnavigation attempt in its parent container(s).

  • Since: 2.12


get_tooltip_markup()

get_tooltip_markup (self) -> str or None

Gets the contents of the tooltip for widget.

  • Returns: the tooltip text, or None. You should free thereturned string with g_free() when done.

  • Since: 2.12


set_tooltip_markup()

set_tooltip_markup (self, markup:str=None)

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 “has-tooltip” to Trueand of the default handler for the “query-tooltip” signal. See also the “tooltip-markup” property and`Gtk.Tooltip:set_markup()`.

  • Since: 2.12

get_tooltip_text()

get_tooltip_text (self) -> str or None

Gets the contents of the tooltip for widget.

  • Returns: the tooltip text, or None. You should free thereturned string with g_free() when done.

  • Since: 2.12


set_tooltip_text()

set_tooltip_text (self, text:str=None)

Sets text as the contents of the tooltip. This function will takecare of setting “has-tooltip” to True and of the defaulthandler for the “query-tooltip” signal. See also the “tooltip-text” property and `Gtk.Tooltip:set_text()`.

  • Since: 2.12

get_tooltip_window()

get_tooltip_window (self) -> Gtk.Window

Returns the Gtk.Window of the current tooltip. This can be theGtk.Window created by default, or the custom tooltip window setusing Gtk.Widget:set_tooltip_window().

  • Returns: The Gtk.Window of the current tooltip.

  • Since: 2.12


set_tooltip_window()

set_tooltip_window (self, custom_window:Gtk.Window=None)

Replaces the default, usually yellow, window used for displayingtooltips with custom_window. GTK+ will take care of showing andhiding custom_window at the right moment, to behave likewise asthe default tooltip window. If custom_window is None, the defaulttooltip window will be used. If the custom window should have the default theming it needs tohave the name “gtk-tooltip”, see Gtk.Widget:set_name().

  • Since: 2.12

get_has_tooltip()

get_has_tooltip (self) -> bool

Returns the current value of the has-tooltip property. See“has-tooltip” for more information.

  • Returns: current value of has-tooltip on widget.

  • Since: 2.12


set_has_tooltip()

set_has_tooltip (self, has_tooltip:bool)

Sets the has-tooltip property on widget to has_tooltip. See“has-tooltip” for more information.

  • Since: 2.12

trigger_tooltip_query()

trigger_tooltip_query (self)

Triggers a tooltip query on the display where the toplevel of widgetis located. See `Gtk.Tooltip:trigger_Tooltip:query()` for moreinformation.

  • Since: 2.12

get_window()

get_window (self) -> Gdk.Window

Returns the widget’s window if it is realized, None otherwise

  • Returns: widget’s window.

  • Since: 2.14


register_window()

register_window (self, window:Gdk.Window)

Registers a GdkWindow with the widget and sets it up so thatthe widget receives events for it. Call Gtk.Widget:unregister_window()when destroying the window. Before 3.8 you needed to call gdk_window_set_user_data() directly to setthis up. This is now deprecated and you should use Gtk.Widget:register_window()instead. Old code will keep working as is, although some new features liketransparency might not work perfectly.

  • Since: 3.8

unregister_window()

unregister_window (self, window:Gdk.Window)

Unregisters a GdkWindow from the widget that was previously set up withGtk.Widget:register_window(). You need to call this when the window isno longer used by the widget, such as when you destroy it.

  • Since: 3.8

get_allocated_width()

get_allocated_width (self) -> int

Returns the width that has currently been allocated to widget.This function is intended to be used when implementing handlersfor the “draw” function.

  • Returns: the width of the widget

get_allocated_height()

get_allocated_height (self) -> int

Returns the height that has currently been allocated to widget.This function is intended to be used when implementing handlersfor the “draw” function.

  • Returns: the height of the widget

get_allocation()

get_allocation (self) -> allocation:Gdk.Rectangle

Retrieves the widget’s allocation. Note, when implementing a Gtk.Container: a widget’s allocation willbe its “adjusted” allocation, that is, the widget’s parentcontainer typically calls Gtk.Widget:size_allocate() with anallocation, and that allocation is then adjusted (to handle marginand alignment for example) before assignment to the widget.Gtk.Widget:get_allocation() returns the adjusted allocation thatwas actually assigned to the widget. The adjusted allocation isguaranteed to be completely contained within theGtk.Widget:size_allocate() allocation, however. So a Gtk.Containeris 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 containerimplementation needs that information it will have to track it itself.

  • Since: 2.18

set_allocation()

set_allocation (self, allocation:Gdk.Rectangle)

Sets the widget’s allocation. This should not be useddirectly, but from within a widget’s size_allocate method. The allocation set should be the “adjusted” or actualallocation. If you’re implementing a Gtk.Container, you want to useGtk.Widget:size_allocate() instead of Gtk.Widget:set_allocation().The Gtk.WidgetClass::adjust_size_allocation virtual method adjusts theallocation inside Gtk.Widget:size_allocate() to create an adjustedallocation.

  • Since: 2.18

get_allocated_baseline()

get_allocated_baseline (self) -> int

Returns the baseline that has currently been allocated to widget.This function is intended to be used when implementing handlersfor the “draw” function, and when allocating childwidgets in “size_allocate”.

  • Returns: the baseline of the widget, or -1 if none

  • Since: 3.10


get_clip()

get_clip (self) -> clip:Gdk.Rectangle

Retrieves the widget’s clip area. The clip area is the area in which all of widget's drawing willhappen. Other toolkits call it the bounding box. Historically, in GTK+ the clip area has been equal to the allocationretrieved via Gtk.Widget:get_allocation().

  • Since: 3.14

set_clip()

set_clip (self, clip:Gdk.Rectangle)

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 upto the parent class), because that function resets the clip. The clip set should be the area that widget draws on. If widget is aGtk.Container, the area must contain all children's clips. If this function is not called by widget during a ::size-allocate handler,the clip will be set to widget's allocation.

  • Since: 3.14

get_app_paintable()

get_app_paintable (self) -> bool

Determines whether the application intends to draw on the widget inan “draw” handler. See Gtk.Widget:set_app_paintable()

  • Returns: True if the widget is app paintable

  • Since: 2.18


get_can_default()

get_can_default (self) -> bool

Determines whether widget can be a default widget. SeeGtk.Widget:set_can_default().

  • Returns: True if widgetcan be a default widget, FALSE otherwise

  • Since: 2.18


set_can_default()

set_can_default (self, can_default:bool)

Specifies whether widget can be a default widget. SeeGtk.Widget:grab_default() for details about the meaning of“default”.

  • Since: 2.18

get_can_focus()

get_can_focus (self) -> bool

Determines whether widget can own the input focus. SeeGtk.Widget:set_can_focus().

  • Returns: True if widgetcan own the input focus, FALSE otherwise

  • Since: 2.18


set_can_focus()

set_can_focus (self, can_focus:bool)

Specifies whether widget can own the input focus. SeeGtk.Widget:grab_focus() for actually setting the input focus on awidget.

  • Since: 2.18

get_double_buffered()

get_double_buffered (self) -> bool

Gtk.Widget:get_double_buffered is deprecated and should not be used in newly-written code. Determines whether the widget is double buffered. See Gtk.Widget:set_double_buffered()

  • Returns: True if the widget is double buffered

  • Since: 2.18


get_has_window()

get_has_window (self) -> bool

Determines whether widget has a GdkWindow of its own. SeeGtk.Widget:set_has_window().

  • Returns: True if widgethas a window, FALSE otherwise

  • Since: 2.18


set_has_window()

set_has_window (self, has_window:bool)

Specifies whether widget has a GdkWindow of its own. Note thatall realized widgets have a non-None “window” pointer(Gtk.Widget:get_window() never returns a None window when a widgetis realized), but for many of them it’s actually the GdkWindow ofone of its parent widgets. Widgets that do not create a window forthemselves in “realize” must announce this bycalling this function with has_window = FALSE. This function should only be called by widget implementations,and they should call it in their init() function.

  • Since: 2.18

get_sensitive()

get_sensitive (self) -> bool

Returns the widget’s sensitivity (in the sense of returningthe value that has been set using Gtk.Widget:set_sensitive()). The effective sensitivity of a widget is however determined by both itsown and its parent widget’s sensitivity. See Gtk.Widget:is_sensitive().

  • Returns: True if the widget is sensitive

  • Since: 2.18


is_sensitive()

is_sensitive (self) -> bool

Returns the widget’s effective sensitivity, which meansit is sensitive itself and also its parent widget is sensitive

  • Returns: True if the widget is effectively sensitive

  • Since: 2.18


get_state()

get_state (self) -> Gtk.StateType

Gtk.Widget:get_state has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.Widget:get_state_flags() instead. Returns the widget’s state. See Gtk.Widget:set_state().

  • Returns: the state of widget.

  • Since: 2.18


get_visible()

get_visible (self) -> bool

Determines whether the widget is visible. If you want totake into account whether the widget’s parent is also marked asvisible, use Gtk.Widget:is_visible() instead. This function does not check if the widget is obscured in any way. See Gtk.Widget:set_visible().

  • Returns: True if the widget is visible

  • Since: 2.18


is_visible()

is_visible (self) -> bool

Determines whether the widget and all its parents are marked asvisible. This function does not check if the widget is obscured in any way. See also Gtk.Widget:get_visible() and Gtk.Widget:set_visible()

  • Returns: True if the widget and all its parents are visible

  • Since: 3.8


set_visible()

set_visible (self, visible:bool)

Sets the visibility state of widget. Note that setting this toTrue doesn’t mean the widget is actually viewable, seeGtk.Widget:get_visible(). This function simply calls Gtk.Widget:show() or Gtk.Widget:hide()but is nicer to use when the visibility of the widget depends onsome condition.

  • Since: 2.18

set_state_flags()

set_state_flags (self, flags:Gtk.StateFlags, clear:bool)

This function is for use in widget implementations. Turns on flagvalues in the current widget state (insensitive, prelighted, etc.). This function accepts the values GTK_STATE_FLAG_DIR_LTR andGTK_STATE_FLAG_DIR_RTL but ignores them. If you want to set the widget'sdirection, use Gtk.Widget:set_direction(). It is worth mentioning that any other state than GTK_STATE_FLAG_INSENSITIVE,will be propagated down to all non-internal children if widget is aGtk.Container, while GTK_STATE_FLAG_INSENSITIVE itself will be propagateddown to all Gtk.Container children by different means than turning on thestate flag down the hierarchy, both Gtk.Widget:get_state_flags() andGtk.Widget:is_sensitive() will make use of these.

  • Since: 3.0

unset_state_flags()

unset_state_flags (self, flags:Gtk.StateFlags)

This function is for use in widget implementations. Turns off flagvalues for the current widget state (insensitive, prelighted, etc.).See Gtk.Widget:set_state_flags().

  • Since: 3.0

get_state_flags()

get_state_flags (self) -> Gtk.StateFlags

Returns the widget state as a flag set. It is worth mentioningthat the effective GTK_STATE_FLAG_INSENSITIVE state will bereturned, that is, also based on parent insensitivity, even ifwidget itself is sensitive.

  • Returns: The state flags for widget

  • Since: 3.0


has_default()

has_default (self) -> bool

Determines whether widget is the current default widget within itstoplevel. See Gtk.Widget:set_can_default().

  • Returns: True if widgetis the current default widget withinits toplevel, FALSE otherwise

  • Since: 2.18


has_focus()

has_focus (self) -> bool

Determines if the widget has the global input focus. SeeGtk.Widget:is_focus() for the difference between having the globalinput focus, and only having the focus within a toplevel.

  • Returns: True if the widget has the global input focus.

  • Since: 2.18


has_visible_focus()

has_visible_focus (self) -> bool

Determines if the widget should show a visible indication thatit has the global input focus. This is a convenience function foruse in ::draw handlers that takes into account whether focusindication should currently be shown in the toplevel window ofwidget. See `Gtk.Window:get_focus_visible()for more informationabout focus indication. To find out if the widget has the global input focus, useGtk.Widget:has_focus()`.

  • Returns: True if the widget should display a “focus rectangle”

  • Since: 3.2


has_grab()

has_grab (self) -> bool

Determines whether the widget is currently grabbing events, so itis the only widget receiving input events (keyboard and mouse). See also `Gtk.Grab:add()`.

  • Returns: True if the widget is in the grab_widgets stack

  • Since: 2.18


has_rc_style()

has_rc_style (self) -> bool

Gtk.Widget:has_rc_style has been deprecated since version 3.0 and should not be used in newly-written code. Use Gtk.StyleContext instead Determines if the widget style has been looked up through the rc mechanism.

  • Returns: True if the widget has been looked up through the rcmechanism, FALSE otherwise.

  • Since: 2.20


is_drawable()

is_drawable (self) -> bool

Determines whether widget can be drawn to. A widget can be drawnto if it is mapped and visible.

  • Returns: True if widgetis drawable, FALSE otherwise

  • Since: 2.18


is_toplevel()

is_toplevel (self) -> bool

Determines whether widget is a toplevel widget. Currently only Gtk.Window and Gtk.Invisible (and out-of-processGtk.Plugs) are toplevel widgets. Toplevel widgets have no parentwidget.

  • Returns: True if widgetis a toplevel, FALSE otherwise

  • Since: 2.18


set_window()

set_window (self, window:Gdk.Window)

Sets a widget’s window. This function should only be used in awidget’s “realize” implementation. The window passed isusually either new window created with gdk_window_new(), or thewindow of its parent widget as returned byGtk.Widget:get_parent_window(). Widgets must indicate whether they will create their own GdkWindowby calling Gtk.Widget:set_has_window(). This is usually done in thewidget’s init() function. Note that this function does not add any reference to window.

  • Since: 2.18

set_receives_default()

set_receives_default (self, receives_default:bool)

Specifies whether widget will be treated as the default widgetwithin its toplevel when it has the focus, even if another widgetis the default. See Gtk.Widget:grab_default() for details about the meaning of“default”.

  • Since: 2.18

get_receives_default()

get_receives_default (self) -> bool

Determines whether widget is always treated as the default widgetwithin its toplevel when it has the focus, even if another widgetis the default. See Gtk.Widget:set_receives_default().

  • Returns: True if widgetacts as the default widget when focused,FALSE otherwise

  • Since: 2.18


set_support_multidevice()

set_support_multidevice (self, support_multidevice:bool)

Enables or disables multiple pointer awareness. If this setting is True,widget will start receiving multiple, per device enter/leave events. Notethat if custom GdkWindows are created in “realize”,gdk_window_set_support_multidevice() will have to be called manually on them.

  • Since: 3.0

get_support_multidevice()

get_support_multidevice (self) -> bool

Returns True if widget is multiple pointer aware. SeeGtk.Widget:set_support_multidevice() for more information.

  • Returns: True if widgetis multidevice aware.

set_realized()

set_realized (self, realized:bool)

Marks the widget as being realized. This function must only be called after all GdkWindows for the widget have been created and registered. This function should only ever be called in a derived widget's“realize” or “unrealize” implementation.

  • Since: 2.20

get_realized()

get_realized (self) -> bool

Determines whether widget is realized.

  • Returns: True if widgetis realized, FALSE otherwise

  • Since: 2.20


set_mapped()

set_mapped (self, mapped:bool)

Marks the widget as being realized. This function should only ever be called in a derived widget's“map” or “unmap” implementation.

  • Since: 2.20

get_mapped()

get_mapped (self) -> bool

Whether the widget is mapped.

  • Returns: True if the widget is mapped, FALSE otherwise.

  • Since: 2.20


get_requisition()

get_requisition (self) -> requisition:Gtk.Requisition

Gtk.Widget:get_requisition has been deprecated since version 3.0 and should not be used in newly-written code. The Gtk.Requisition cache on the widget wasremoved, If you need to cache sizes across requests and allocations,add an explicit cache to the widget in question instead. Retrieves the widget’s requisition. This function should only be used by widget implementations inorder to figure whether the widget’s requisition has actuallychanged after some internal state change (so that they can callGtk.Widget:queue_resize() instead of Gtk.Widget:queue_draw()). Normally, Gtk.Widget:size_request() should be used.

  • Since: 2.20

device_is_shadowed()

device_is_shadowed (self, device:Gdk.Device) -> bool

Returns True if device has been shadowed by a GTK+device grab on another widget, so it would stop sendingevents to widget. This may be used in the“grab-notify” signal to check for specificdevices. See `Gtk.DeviceGrab:add()`.

  • Returns: True if there is an ongoing grab on deviceby another Gtk.Widget than widget.

  • Since: 3.0


get_modifier_mask()

get_modifier_mask (self, intent:Gdk.ModifierIntent) -> Gdk.ModifierType

Returns the modifier mask the widget’s windowing system backenduses for a particular purpose. See gdk_keymap_get_modifier_mask().

  • Returns: the modifier mask used for intent.

  • Since: 3.4


insert_action_group()

insert_action_group (self, name:str, group:Gio.ActionGroup=None)

Inserts group into widget. Children of widget that implementGtk.Actionable can then be associated with actions in group bysetting their “action-name” toprefix.action-name. If group is None, a previously inserted group for name is removedfrom widget.

  • Since: 3.6

get_opacity()

get_opacity (self) -> float

Fetches the requested opacity for this widget.See Gtk.Widget:set_opacity().

  • Returns: the requested opacity for this widget.

  • Since: 3.8


set_opacity()

set_opacity (self, opacity:float)

Request the widget to be rendered partially transparent,with opacity 0 being fully transparent and 1 fully opaque. (Opacity valuesare clamped to the [0,1] range.).This works on both toplevel widget, and child widgets, although thereare some limitations: For toplevel widgets this depends on the capabilities of the windowingsystem. On X11 this has any effect only on X screens with a compositing managerrunning. See Gtk.Widget:is_composited(). On Windows it should workalways, although setting a window’s opacity after the window has beenshown causes it to flicker once on Windows. For child widgets it doesn’t work if any affected widget has a native window, ordisables double buffering.

  • Since: 3.8

list_action_prefixes()

list_action_prefixes (self) -> list

Retrieves a None-terminated array of strings containing the prefixes ofGActionGroup's available to widget.

  • Returns: a None-terminated array of strings.

  • Since: 3.16


get_action_group()

get_action_group (self, prefix:str) -> Gio.ActionGroup or None

Retrieves the GActionGroup that was registered using prefix. The resultingGActionGroup may have been registered to widget or any Gtk.Widget in itsancestry. If no action group was found matching prefix, then None is returned.

  • Returns: A GActionGroup or None.

  • Since: 3.16


get_path()

get_path (self) -> Gtk.WidgetPath

Returns the Gtk.WidgetPath representing widget, if the widgetis not connected to a toplevel widget, a partial path will becreated.

  • Returns: The Gtk.WidgetPath representing widget.

get_style_context()

get_style_context (self) -> Gtk.StyleContext

Returns the style context associated to widget.

  • Returns: a Gtk.StyleContext. This memory is owned by widgetandmust not be freed.

reset_style()

reset_style (self)

Updates the style context of widget and all descendantsby updating its widget path. Gtk.Containers may wantto use this on a child when reordering it in a way that a differentstyle might apply to it. See also `Gtk.Container:get_path_for_child()`.

  • Since: 3.0

get_preferred_height()

get_preferred_height (self) -> minimum_height:int, natural_height:int

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 theGtk.WidgetClass::adjust_size_request virtual method and by anyGtk.SizeGroups that have been applied. That is, the returned requestis the one that should be used for layout, not necessarily the onereturned by the widget itself.

  • Since: 3.0

get_preferred_width()

get_preferred_width (self) -> minimum_width:int, natural_width:int

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 theGtk.WidgetClass::adjust_size_request virtual method and by anyGtk.SizeGroups that have been applied. That is, the returned requestis the one that should be used for layout, not necessarily the onereturned by the widget itself.

  • Since: 3.0

get_preferred_height_for_width()

get_preferred_height_for_width (self, width:int) -> minimum_height:int, natural_height:int

Retrieves a widget’s minimum and natural height if it would be giventhe specified width. The returned request will be modified by theGtk.WidgetClass::adjust_size_request virtual method and by anyGtk.SizeGroups that have been applied. That is, the returned requestis the one that should be used for layout, not necessarily the onereturned by the widget itself.

  • Since: 3.0

get_preferred_width_for_height()

get_preferred_width_for_height (self, height:int) -> minimum_width:int, natural_width:int

Retrieves a widget’s minimum and natural width if it would be giventhe specified height. The returned request will be modified by theGtk.WidgetClass::adjust_size_request virtual method and by anyGtk.SizeGroups that have been applied. That is, the returned requestis the one that should be used for layout, not necessarily the onereturned by the widget itself.

  • Since: 3.0

get_preferred_height_and_baseline_for_width()

get_preferred_height_and_baseline_for_width (self, width:int) -> 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 giventhe specified width, or the default height if width is -1. The baselines may be -1 which meansthat no baseline is requested for this widget. The returned request will be modified by theGtk.WidgetClass::adjust_size_request and Gtk.WidgetClass::adjust_baseline_request virtual methodsand by any Gtk.SizeGroups that have been applied. That is, the returned requestis the one that should be used for layout, not necessarily the onereturned by the widget itself.

  • Since: 3.10

get_request_mode()

get_request_mode (self) -> Gtk.SizeRequestMode

Gets whether the widget prefers a height-for-width layoutor a width-for-height layout. Gtk.Bin widgets generally propagate the preference oftheir child, container widgets need to request something either incontext of their children or in context of their allocationcapabilities.

  • Returns: The Gtk.SizeRequestMode preferred by widget.

  • Since: 3.0


get_preferred_size()

get_preferred_size (self) -> minimum_size:Gtk.Requisition, natural_size:Gtk.Requisition

Retrieves the minimum and natural size of a widget, takinginto account the widget’s preference for height-for-width management. This is used to retrieve a suitable size by container widgets which donot impose any restrictions on the child placement. It can be usedto deduce toplevel window and menu sizes as well as child widgets infree-form containers such as Gtk.Layout. Handle with care. Note that the natural height of a height-for-widthwidget will generally be a smaller size than the minimum height, since the requiredheight for the natural width is generally smaller than the required height forthe minimum width. Use Gtk.Widget:get_preferred_height_and_baseline_for_width() if you want to supportbaseline alignment.

  • Since: 3.0

get_halign()

get_halign (self) -> Gtk.Align

Gets the value of the “halign” property. For backwards compatibility reasons this method will never returnGTK_ALIGN_BASELINE, but instead it will convert it toGTK_ALIGN_FILL. Baselines are not supported for horizontalalignment.

  • Returns: the horizontal alignment of widget

set_halign()

set_halign (self, align:Gtk.Align)

Sets the horizontal alignment of widget.See the “halign” property.


get_valign()

get_valign (self) -> Gtk.Align

Gets the value of the “valign” property. For backwards compatibility reasons this method will never returnGTK_ALIGN_BASELINE, but instead it will convert it toGTK_ALIGN_FILL. If your widget want to support baseline alignedchildren it must use Gtk.Widget:get_valign_with_baseline(), org_object_get (widget, "valign", &amp;value, None), which willalso report the true value.

  • Returns: the vertical alignment of widget, ignoring baseline alignment

get_valign_with_baseline()

get_valign_with_baseline (self) -> Gtk.Align

Gets the value of the “valign” property, includingGTK_ALIGN_BASELINE.

  • Returns: the vertical alignment of widget

  • Since: 3.10


set_valign()

set_valign (self, align:Gtk.Align)

Sets the vertical alignment of widget.See the “valign” property.


get_margin_left()

get_margin_left (self) -> int

Gtk.Widget:get_margin_left has been deprecated since version 3.12 and should not be used in newly-written code. Use Gtk.Widget:get_margin_start() instead. Gets the value of the “margin-left” property.

  • Returns: The left margin of widget

  • Since: 3.0


set_margin_left()

set_margin_left (self, margin:int)

Gtk.Widget:set_margin_left has been deprecated since version 3.12 and should not be used in newly-written code. Use Gtk.Widget:set_margin_start() instead. Sets the left margin of widget.See the “margin-left” property.

  • Since: 3.0

get_margin_right()

get_margin_right (self) -> int

Gtk.Widget:get_margin_right has been deprecated since version 3.12 and should not be used in newly-written code. Use Gtk.Widget:get_margin_end() instead. Gets the value of the “margin-right” property.

  • Returns: The right margin of widget

  • Since: 3.0


set_margin_right()

set_margin_right (self, margin:int)

Gtk.Widget:set_margin_right has been deprecated since version 3.12 and should not be used in newly-written code. Use Gtk.Widget:set_margin_end() instead. Sets the right margin of widget.See the “margin-right” property.

  • Since: 3.0

get_margin_start()

get_margin_start (self) -> int

Gets the value of the “margin-start” property.

  • Returns: The start margin of widget

  • Since: 3.12


set_margin_start()

set_margin_start (self, margin:int)

Sets the start margin of widget.See the “margin-start” property.

  • Since: 3.12

get_margin_end()

get_margin_end (self) -> int

Gets the value of the “margin-end” property.

  • Returns: The end margin of widget

  • Since: 3.12


set_margin_end()

set_margin_end (self, margin:int)

Sets the end margin of widget.See the “margin-end” property.

  • Since: 3.12

get_margin_top()

get_margin_top (self) -> int

Gets the value of the “margin-top” property.

  • Returns: The top margin of widget

  • Since: 3.0


set_margin_top()

set_margin_top (self, margin:int)

Sets the top margin of widget.See the “margin-top” property.

  • Since: 3.0

get_margin_bottom()

get_margin_bottom (self) -> int

Gets the value of the “margin-bottom” property.

  • Returns: The bottom margin of widget

  • Since: 3.0


set_margin_bottom()

set_margin_bottom (self, margin:int)

Sets the bottom margin of widget.See the “margin-bottom” property.

  • Since: 3.0

get_hexpand()

get_hexpand (self) -> bool

Gets whether the widget would like any available extra horizontalspace. When a user resizes a Gtk.Window, widgets with expand=Truegenerally receive the extra space. For example, a list orscrollable area or document in your window would often be set toexpand. Containers should use Gtk.Widget:compute_expand() rather thanthis function, to see whether a widget, or any of its children,has the expand flag set. If any child of a widget wants toexpand, the parent may ask to expand also. This function only looks at the widget’s own hexpand flag, ratherthan computing whether the entire widget tree rooted at this widgetwants to expand.

  • Returns: whether hexpand flag is set

set_hexpand()

set_hexpand (self, expand:bool)

Sets whether the widget would like any available extra horizontalspace. When a user resizes a Gtk.Window, widgets with expand=Truegenerally receive the extra space. For example, a list orscrollable area or document in your window would often be set toexpand. Call this function to set the expand flag if you would like yourwidget to become larger horizontally when the window has extraroom. By default, widgets automatically expand if any of their childrenwant to expand. (To see if a widget will automatically expand givenits current children and state, call Gtk.Widget:compute_expand(). Acontainer can decide how the expandability of children affects theexpansion of the container by overriding the compute_expand virtualmethod on Gtk.Widget.). Setting hexpand explicitly with this function will override theautomatic expand behavior. This function forces the widget to expand or not to expand,regardless of children. The override occurs becauseGtk.Widget:set_hexpand() sets the hexpand-set property (seeGtk.Widget:set_hexpand_set()) which causes the widget’s hexpandvalue to be used, rather than looking at children and widget state.


get_hexpand_set()

get_hexpand_set (self) -> bool

Gets whether Gtk.Widget:set_hexpand() has been used toexplicitly set the expand flag on this widget. If hexpand is set, then it overrides any computedexpand value based on child widgets. If hexpand is notset, then the expand value depends on whether anychildren of the widget would like to expand. There are few reasons to use this function, but it’s herefor completeness and consistency.

  • Returns: whether hexpand has been explicitly set

set_hexpand_set()

set_hexpand_set (self, set:bool)

Sets whether the hexpand flag (see Gtk.Widget:get_hexpand()) willbe used. The hexpand-set property will be set automatically when you callGtk.Widget:set_hexpand() to set hexpand, so the most likelyreason to use this function would be to unset an explicit expandflag. If hexpand is set, then it overrides any computedexpand value based on child widgets. If hexpand is notset, then the expand value depends on whether anychildren of the widget would like to expand. There are few reasons to use this function, but it’s herefor completeness and consistency.


get_vexpand()

get_vexpand (self) -> bool

Gets whether the widget would like any available extra verticalspace. See Gtk.Widget:get_hexpand() for more detail.

  • Returns: whether vexpand flag is set

set_vexpand()

set_vexpand (self, expand:bool)

Sets whether the widget would like any available extra verticalspace. See Gtk.Widget:set_hexpand() for more detail.


get_vexpand_set()

get_vexpand_set (self) -> bool

Gets whether Gtk.Widget:set_vexpand() has been used toexplicitly set the expand flag on this widget. See Gtk.Widget:get_hexpand_set() for more detail.

  • Returns: whether vexpand has been explicitly set

set_vexpand_set()

set_vexpand_set (self, set:bool)

Sets whether the vexpand flag (see Gtk.Widget:get_vexpand()) willbe used. See Gtk.Widget:set_hexpand_set() for more detail.


queue_compute_expand()

queue_compute_expand (self)

Mark widget as needing to recompute its expand flags. Callthis function when setting legacy expand child propertieson the child of a container. See Gtk.Widget:compute_expand().


compute_expand()

compute_expand (self, orientation:Gtk.Orientation) -> bool

Computes whether a container should give this widget extra spacewhen possible. Containers should check this, rather thanlooking at Gtk.Widget:get_hexpand() or Gtk.Widget:get_vexpand(). This function already checks whether the widget is visible, sovisibility does not need to be checked separately. Non-visiblewidgets are not expanded. The computed expand value uses either the expand setting explicitlyset on the widget itself, or, if none has been explicitly set,the widget may expand if some of its children do.

  • Returns: whether widget tree rooted here should be expanded

init_template()

init_template (self)

Creates and initializes child widgets defined in templates. Thisfunction must be called in the instance initializer for anyclass which assigned itself a template using Gtk.Widget:class_set_template() It is important to call this function in the instance initializerof a Gtk.Widget subclass and not in GObject.constructed() orGObject.constructor() for two reasons. One reason is that generally derived widgets will assume that parentclass composite widgets have been created in their instanceinitializers. Another reason is that when calling g_object_new() on a widget withcomposite templates, it’s important to build the composite widgetsbefore the construct properties are set. Properties passed to g_object_new()should take precedence over properties set in the private template XML.

  • Since: 3.10

get_template_child()

get_template_child (self, widget_type:GType, name:str) -> GObject.Object

Fetch an object build from the template XML for widget_type in this widget instance. This will only report children which were previously declared withGtk.Widget:class_bind_template_child_full() or one of itsvariants. This function is only meant to be called for code which is private to the widget_type whichdeclared the child and is meant for language bindings which cannot easily make useof the GObject structure offsets.

  • Returns: The object built in the template XML with the id name.

results matching ""

    No results matching ""