Gtk.WidgetClass

Fields

Name Type Access Description
activate_signal int r The signal to emit when a widget of this class is activated, Gtk.Widget.activate() handles the emission. Implementation of this signal is optional.
adjust_baseline_allocation object r  
adjust_baseline_request object r  
adjust_size_allocation object r  
adjust_size_request object r  
button_press_event object r  
button_release_event object r  
can_activate_accel object r  
child_notify object r  
composited_changed object r  
compute_expand object r  
configure_event object r  
damage_event object r  
delete_event object r  
destroy object r  
destroy_event object r  
direction_changed object r  
dispatch_child_properties_changed object r  
drag_begin object r  
drag_data_delete object r  
drag_data_get object r  
drag_data_received object r  
drag_drop object r  
drag_end object r  
drag_failed object r  
drag_leave object r  
drag_motion object r  
draw object r  
enter_notify_event object r  
event object r  
focus object r  
focus_in_event object r  
focus_out_event object r  
get_accessible object r  
get_preferred_height object r  
get_preferred_height_and_baseline_for_width object r  
get_preferred_height_for_width object r  
get_preferred_width object r  
get_preferred_width_for_height object r  
get_request_mode object r  
grab_broken_event object r  
grab_focus object r  
grab_notify object r  
hide object r  
hierarchy_changed object r  
key_press_event object r  
key_release_event object r  
keynav_failed object r  
leave_notify_event object r  
map object r  
map_event object r  
mnemonic_activate object r  
motion_notify_event object r  
move_focus object r  
parent_class GObject.InitiallyUnownedClass r The object class structure needs to be the first element in the widget class structure in order for the class mechanism to work correctly. This allows a Gtk.WidgetClass pointer to be cast to a GObject.ObjectClass pointer.
parent_set object r  
popup_menu object r  
property_notify_event object r  
proximity_in_event object r  
proximity_out_event object r  
query_tooltip object r  
queue_draw_region object r  
realize object r  
screen_changed object r  
scroll_event object r  
selection_clear_event object r  
selection_get object r  
selection_notify_event object r  
selection_received object r  
selection_request_event object r  
show object r  
show_all object r  
show_help object r  
size_allocate object r  
state_changed object r  
state_flags_changed object r  
style_set object r  
style_updated object r  
touch_event object r  
unmap object r  
unmap_event object r  
unrealize object r  
visibility_notify_event object r  
window_state_event object r  

Methods

  bind_template_callback_full (callback_name, callback_symbol)
  bind_template_child_full (name, internal_child, struct_offset)
  find_style_property (property_name)
  get_css_name ()
  install_style_property (pspec)
  list_style_properties ()
  set_accessible_role (role)
  set_accessible_type (type)
  set_connect_func (connect_func, *connect_data)
  set_css_name (name)
  set_template (template_bytes)
  set_template_from_resource (resource_name)

Details

class Gtk.WidgetClass
bind_template_callback_full(callback_name, callback_symbol)[source]
Parameters:
  • callback_name (str) – The name of the callback as expected in the template XML
  • callback_symbol (GObject.Callback) – The callback symbol

Declares a callback_symbol to handle callback_name from the template XML defined for widget_type. See Gtk.Builder.add_callback_symbol().

Note that this must be called from a composite widget classes class initializer after calling Gtk.WidgetClass.set_template().

New in version 3.10.

bind_template_child_full(name, internal_child, struct_offset)[source]
Parameters:
  • name (str) – The “id” of the child defined in the template XML
  • internal_child (bool) – Whether the child should be accessible as an “internal-child” when this class is used in Gtk.Builder XML
  • struct_offset (int) – The structure offset into the composite widget’s instance public or private structure where the automated child pointer should be set, or 0 to not assign the pointer.

Automatically assign an object declared in the class template XML to be set to a location on a freshly built instance’s private data, or alternatively accessible via Gtk.Widget.get_template_child().

The struct can point either into the public instance, then you should use G_STRUCT_OFFSET(WidgetType, member) for struct_offset, or in the private struct, then you should use G_PRIVATE_OFFSET(WidgetType, member).

An explicit strong reference will be held automatically for the duration of your instance’s life cycle, it will be released automatically when GObject.Object.do_dispose() runs on your instance and if a struct_offset that is != 0 is specified, then the automatic location in your instance public or private data will be set to None. You can however access an automated child pointer the first time your classes GObject.Object.do_dispose() runs, or alternatively in Gtk.Widget.do_destroy().

If internal_child is specified, Gtk.Buildable.do_get_internal_child() will be automatically implemented by the Gtk.Widget class so there is no need to implement it manually.

The wrapper macros gtk_widget_class_bind_template_child(), gtk_widget_class_bind_template_child_internal(), gtk_widget_class_bind_template_child_private() and gtk_widget_class_bind_template_child_internal_private() might be more convenient to use.

Note that this must be called from a composite widget classes class initializer after calling Gtk.WidgetClass.set_template().

New in version 3.10.

find_style_property(property_name)[source]
Parameters:property_name (str) – the name of the style property to find
Returns:the GObject.ParamSpec of the style property or None if class has no style property with that name.
Return type:GObject.ParamSpec

Finds a style property of a widget class by name.

New in version 2.2.

get_css_name()[source]
Returns:the CSS name of the given class
Return type:str

Gets the name used by this class for matching in CSS code. See Gtk.WidgetClass.set_css_name() for details.

New in version 3.20.

install_style_property(pspec)[source]
Parameters:pspec (GObject.ParamSpec) – the GObject.ParamSpec for the property

Installs a style property on a widget class. The parser for the style property is determined by the value type of pspec.

list_style_properties()[source]
Returns:a newly allocated array of GObject.ParamSpec. The array must be freed with GLib.free().
Return type:[GObject.ParamSpec]

Returns all style properties of a widget class.

New in version 2.2.

set_accessible_role(role)[source]
Parameters:role (Atk.Role) – The role to use for accessibles created for self

Sets the default Atk.Role to be set on accessibles created for widgets of self. Accessibles may decide to not honor this setting if their role reporting is more refined. Calls to Gtk.WidgetClass.set_accessible_type() will reset this value.

In cases where you want more fine-grained control over the role of accessibles created for self, you should provide your own accessible type and use Gtk.WidgetClass.set_accessible_type() instead.

If role is Atk.Role.INVALID, the default role will not be changed and the accessible’s default role will be used instead.

This function should only be called from class init functions of widgets.

New in version 3.2.

set_accessible_type(type)[source]
Parameters:type (GObject.GType) – The object type that implements the accessible for self

Sets the type to be used for creating accessibles for widgets of self. The given type must be a subtype of the type used for accessibles of the parent class.

This function should only be called from class init functions of widgets.

New in version 3.2.

set_connect_func(connect_func, *connect_data)[source]
Parameters:

For use in language bindings, this will override the default Gtk.BuilderConnectFunc to be used when parsing Gtk.Builder XML from this class’s template data.

Note that this must be called from a composite widget classes class initializer after calling Gtk.WidgetClass.set_template().

New in version 3.10.

set_css_name(name)[source]
Parameters:name (str) – name to use

Sets the name to be used for CSS matching of widgets.

If this function is not called for a given class, the name of the parent class is used.

New in version 3.20.

set_template(template_bytes)[source]
Parameters:template_bytes (GLib.Bytes) – A GLib.Bytes holding the Gtk.Builder XML

This should be called at class initialization time to specify the Gtk.Builder XML to be used to extend a widget.

For convenience, Gtk.WidgetClass.set_template_from_resource() is also provided.

Note that any class that installs templates must call Gtk.Widget.init_template() in the widget’s instance initializer.

New in version 3.10.

set_template_from_resource(resource_name)[source]
Parameters:resource_name (str) – The name of the resource to load the template from

A convenience function to call Gtk.WidgetClass.set_template().

Note that any class that installs templates must call Gtk.Widget.init_template() in the widget’s instance initializer.

New in version 3.10.