Gtk.WidgetClass¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
activate_signal |
r |
The signal to emit when a widget of this class is activated, |
|
adjust_baseline_allocation |
r |
||
adjust_baseline_request |
r |
||
adjust_size_allocation |
r |
Convert an initial size allocation assigned by a |
|
adjust_size_request |
r |
Convert an initial size request from a widget’s |
|
button_press_event |
r |
Signal will be emitted when a button (typically from a mouse) is pressed. |
|
button_release_event |
r |
Signal will be emitted when a button (typically from a mouse) is released. |
|
can_activate_accel |
r |
Signal allows applications and derived widgets to override the default |
|
child_notify |
r |
Signal emitted for each child property that has changed on an object. |
|
composited_changed |
r |
Signal emitted when the composited status of widgets screen changes. See |
|
compute_expand |
r |
Computes whether a container should give this widget extra space when possible. |
|
configure_event |
r |
Signal will be emitted when the size, position or stacking of the widget’s window has changed. |
|
damage_event |
r |
Signal emitted when a redirected window belonging to widget gets drawn into. |
|
delete_event |
r |
Signal emitted if a user requests that a toplevel window is closed. |
|
destroy |
r |
Signals that all holders of a reference to the widget should release the reference that they hold. |
|
destroy_event |
r |
Signal is emitted when a |
|
direction_changed |
r |
Signal emitted when the text direction of a widget changes. |
|
dispatch_child_properties_changed |
r |
Seldomly overidden. |
|
drag_begin |
r |
Signal emitted on the drag source when a drag is started. |
|
drag_data_delete |
r |
Signal emitted on the drag source when a drag with the action |
|
drag_data_get |
r |
Signal emitted on the drag source when the drop site requests the data which is dragged. |
|
drag_data_received |
r |
Signal emitted on the drop site when the dragged data has been received. |
|
drag_drop |
r |
Signal emitted on the drop site when the user drops the data onto the widget. |
|
drag_end |
r |
Signal emitted on the drag source when a drag is finished. |
|
drag_failed |
r |
Signal emitted on the drag source when a drag has failed. |
|
drag_leave |
r |
Signal emitted on the drop site when the cursor leaves the widget. |
|
drag_motion |
r |
signal emitted on the drop site when the user moves the cursor over the widget during a drag. |
|
draw |
r |
Signal emitted when a widget is supposed to render itself. |
|
enter_notify_event |
r |
Signal event will be emitted when the pointer enters the widget’s window. |
|
event |
r |
The GTK+ main loop will emit three signals for each GDK event delivered to a widget: one generic |
|
focus |
r |
||
focus_in_event |
r |
Signal emitted when the keyboard focus enters the widget’s window. |
|
focus_out_event |
r |
Signal emitted when the keyboard focus leaves the widget’s window. |
|
get_accessible |
r |
Returns the accessible object that describes the widget to an assistive technology. |
|
get_preferred_height |
r |
This is called by containers to obtain the minimum and natural height of a widget. A widget that does not actually trade any height for width or width for height only has to implement these two virtual methods ( |
|
get_preferred_height_and_baseline_for_width |
r |
||
get_preferred_height_for_width |
r |
This is similar to |
|
get_preferred_width |
r |
This is called by containers to obtain the minimum and natural width of a widget. A widget will never be allocated a width less than its minimum and will only ever be allocated a width greater than the natural width once all of the said widget’s siblings have received their natural widths. Furthermore, a widget will only ever be allocated a width greater than its natural width if it was configured to receive extra expand space from its parent container. |
|
get_preferred_width_for_height |
r |
This is analogous to |
|
get_request_mode |
r |
This allows a widget to tell its parent container whether it prefers to be allocated in |
|
grab_broken_event |
r |
Signal emitted when a pointer or keyboard grab on a window belonging to widget gets broken. |
|
grab_focus |
r |
Causes widget to have the keyboard focus for the |
|
grab_notify |
r |
Signal emitted when a widget becomes shadowed by a GTK+ grab (not a pointer or keyboard grab) on another widget, or when it becomes unshadowed due to a grab being removed. |
|
hide |
r |
Signal emitted when widget is hidden. |
|
hierarchy_changed |
r |
Signal emitted when the anchored state of a widget changes. |
|
key_press_event |
r |
Signal emitted when a key is pressed. |
|
key_release_event |
r |
Signal is emitted when a key is released. |
|
keynav_failed |
r |
Signal emitted if keyboard navigation fails. |
|
leave_notify_event |
r |
Will be emitted when the pointer leaves the widget’s window. |
|
map |
r |
Signal emitted when widget is going to be mapped, that is when the widget is visible (which is controlled with |
|
map_event |
r |
Signal emitted when the widget’s window is mapped. |
|
mnemonic_activate |
r |
Activates the widget if group_cycling is |
|
motion_notify_event |
r |
Signal emitted when the pointer moves over the widget’s |
|
move_focus |
r |
Signal emitted when a change of focus is requested |
|
parent_class |
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 |
|
parent_set |
r |
Signal emitted when a new parent has been set on a widget. |
|
popup_menu |
r |
Signal emitted whenever a widget should pop up a context menu. |
|
property_notify_event |
r |
Signal will be emitted when a property on the widget’s window has been changed or deleted. |
|
proximity_in_event |
r |
||
proximity_out_event |
r |
||
query_tooltip |
r |
Signal emitted when “has-tooltip” is |
|
queue_draw_region |
r |
Invalidates the area of widget defined by region by calling |
|
realize |
r |
Signal emitted when widget is associated with a |
|
screen_changed |
r |
Signal emitted when the screen of a widget has changed. |
|
scroll_event |
r |
Signal emitted when a button in the 4 to 7 range is pressed. |
|
selection_clear_event |
r |
Signal will be emitted when the the widget’s window has lost ownership of a selection. |
|
selection_get |
r |
||
selection_notify_event |
r |
||
selection_received |
r |
||
selection_request_event |
r |
Signal will be emitted when another client requests ownership of the selection owned by the widget’s window. |
|
show |
r |
Signal emitted when widget is shown |
|
show_all |
r |
Recursively shows a widget, and any child widgets (if the widget is a container). |
|
show_help |
r |
||
size_allocate |
r |
Signal emitted to get the widget allocation. |
|
state_changed |
r |
Signal emitted when the widget state changes. Deprecated: 3.0 |
|
state_flags_changed |
r |
Signal emitted when the widget state changes, see |
|
style_set |
r |
Signal emitted when a new style has been set on a widget. Deprecated: 3.0 |
|
style_updated |
r |
Signal emitted when the |
|
touch_event |
r |
Signal emitted when a touch event happens |
|
unmap |
r |
Signal emitted when widget is going to be unmapped, which means that either it or any of its parents up to the toplevel widget have been set as hidden. |
|
unmap_event |
r |
Signal will be emitted when the widget’s window is unmapped. |
|
unrealize |
r |
Signal emitted when the |
|
visibility_notify_event |
r |
Signal emitted when the widget’s window is obscured or unobscured. |
|
window_state_event |
r |
Signal emitted when the state of the toplevel window associated to the widget changes. |
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 XMLcallback_symbol (
GObject.Callback
) – The callback symbol
Declares a callback_symbol to handle callback_name from the template XML defined for widget_type. See
Gtk.Builder.add_callback_symbol
().Note that this must be called from a composite widget classes class initializer after calling
Gtk.WidgetClass.set_template
().New in version 3.10.
- bind_template_child_full(name, internal_child, struct_offset)[source]¶
- Parameters:
name (
str
) – The “id” of the child defined in the template XMLinternal_child (
bool
) – Whether the child should be accessible as an “internal-child” when this class is used inGtk.Builder
XMLstruct_offset (
int
) – The structure offset into the composite widget’s instance public or private structure where the automated child pointer should be set, or 0 to not assign the pointer.
Automatically assign an object declared in the class template XML to be set to a location on a freshly built instance’s private data, or alternatively accessible via
Gtk.Widget.get_template_child
().The struct can point either into the public instance, then you should use G_STRUCT_OFFSET(WidgetType, member) for struct_offset, or in the private struct, then you should use G_PRIVATE_OFFSET(WidgetType, member).
An explicit strong reference will be held automatically for the duration of your instance’s life cycle, it will be released automatically when
GObject.Object.do_dispose
() runs on your instance and if a struct_offset that is != 0 is specified, then the automatic location in your instance public or private data will be set toNone
. You can however access an automated child pointer the first time your classesGObject.Object.do_dispose
() runs, or alternatively inGtk.Widget.do_destroy
().If internal_child is specified,
Gtk.Buildable.do_get_internal_child
() will be automatically implemented by theGtk.Widget
class so there is no need to implement it manually.The wrapper macros gtk_widget_class_bind_template_child(), gtk_widget_class_bind_template_child_internal(), gtk_widget_class_bind_template_child_private() and gtk_widget_class_bind_template_child_internal_private() might be more convenient to use.
Note that this must be called from a composite widget classes class initializer after calling
Gtk.WidgetClass.set_template
().New in version 3.10.
- 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 orNone
if class has no style property with that name.- Return type:
Finds a style property of a widget class by name.
New in version 2.2.
- get_css_name()[source]¶
- Returns:
the CSS name of the given class
- Return type:
Gets the name used by this class for matching in CSS code. See
Gtk.WidgetClass.set_css_name
() for details.New in version 3.20.
- install_style_property(pspec)[source]¶
- Parameters:
pspec (
GObject.ParamSpec
) – theGObject.ParamSpec
for the property
Installs a style property on a widget class. The parser for the style property is determined by the value type of pspec.
- list_style_properties()[source]¶
- Returns:
a newly allocated array of
GObject.ParamSpec
. The array must be freed withGLib.free
().- Return type:
Returns all style properties of a widget class.
New in version 2.2.
- 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 toGtk.WidgetClass.set_accessible_type
() will reset this value.In cases where you want more fine-grained control over the role of accessibles created for self, you should provide your own accessible type and use
Gtk.WidgetClass.set_accessible_type
() instead.If role is
Atk.Role.INVALID
, the default role will not be changed and the accessible’s default role will be used instead.This function should only be called from class init functions of widgets.
New in version 3.2.
- 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:
connect_func (
Gtk.BuilderConnectFunc
) – TheGtk.BuilderConnectFunc
to use when connecting signals in the class templateconnect_data (
object
orNone
) – The data to pass to connect_func
For use in language bindings, this will override the default
Gtk.BuilderConnectFunc
to be used when parsingGtk.Builder
XML from this class’s template data.Note that this must be called from a composite widget classes class initializer after calling
Gtk.WidgetClass.set_template
().New in version 3.10.
- 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
) – AGLib.Bytes
holding theGtk.Builder
XML
This should be called at class initialization time to specify the
Gtk.Builder
XML to be used to extend a widget.For convenience,
Gtk.WidgetClass.set_template_from_resource
() is also provided.Note that any class that installs templates must call
Gtk.Widget.init_template
() in the widget’s instance initializer.New in version 3.10.
- 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.