Callbacks

AccelGroupActivate (accel_group, acceleratable, keyval, modifier)

AccelGroupFindFunc (key, closure, *data)

AccelMapForeach (data, accel_path, accel_key, accel_mods, changed)

AssistantPageFunc (current_page, *data)

BuilderConnectFunc (builder, object, signal_name, handler_name, connect_object, flags, *user_data)

CalendarDetailFunc (calendar, year, month, day, *user_data)

Callback (widget, *data)

CellAllocCallback (renderer, cell_area, cell_background, *data)

CellCallback (renderer, *data)

CellLayoutDataFunc (cell_layout, cell, tree_model, iter, *data)

ClipboardClearFunc (clipboard, user_data_or_owner)

ClipboardGetFunc (clipboard, selection_data, info, user_data_or_owner)

ClipboardImageReceivedFunc (clipboard, pixbuf, *data)

ClipboardReceivedFunc (clipboard, selection_data, *data)

ClipboardRichTextReceivedFunc (clipboard, format, text, length, *data)

ClipboardTargetsReceivedFunc (clipboard, atoms, *data)

ClipboardTextReceivedFunc (clipboard, text, *data)

ClipboardURIReceivedFunc (clipboard, uris, *data)

ColorSelectionChangePaletteFunc (colors)

ColorSelectionChangePaletteWithScreenFunc (screen, colors)

EntryCompletionMatchFunc (completion, key, iter, *user_data)

FileFilterFunc (filter_info, *data)

FlowBoxCreateWidgetFunc (item, *user_data)

FlowBoxFilterFunc (child, *user_data)

FlowBoxForeachFunc (box, child, *user_data)

FlowBoxSortFunc (child1, child2, *user_data)

FontFilterFunc (family, face, *data)

IconViewForeachFunc (icon_view, path, *data)

KeySnoopFunc (grab_widget, event, *func_data)

ListBoxCreateWidgetFunc (item, *user_data)

ListBoxFilterFunc (row, *user_data)

ListBoxForeachFunc (box, row, *user_data)

ListBoxSortFunc (row1, row2, *user_data)

ListBoxUpdateHeaderFunc (row, before, *user_data)

MenuDetachFunc (attach_widget, menu)

MenuPositionFunc (menu, x, y, *user_data)

ModuleDisplayInitFunc (display)

ModuleInitFunc (argv)

PageSetupDoneFunc (page_setup, *data)

PrintSettingsFunc (key, value, *user_data)

RcPropertyParser (pspec, rc_string, property_value)

RecentFilterFunc (filter_info, *user_data)

RecentSortFunc (a, b, *user_data)

StylePropertyParser (string, value)

TextBufferDeserializeFunc (register_buffer, content_buffer, iter, data, create_tags, *user_data)

TextBufferSerializeFunc (register_buffer, content_buffer, start, end, *user_data)

TextCharPredicate (ch, *user_data)

TextTagTableForeach (tag, *data)

TickCallback (widget, frame_clock, *user_data)

TranslateFunc (path, *func_data)

TreeCellDataFunc (tree_column, cell, tree_model, iter, *data)

TreeDestroyCountFunc (tree_view, path, children, *user_data)

TreeIterCompareFunc (model, a, b, *user_data)

TreeModelFilterModifyFunc (model, iter, column, *data)

TreeModelFilterVisibleFunc (model, iter, *data)

TreeModelForeachFunc (model, path, iter, *data)

TreeSelectionForeachFunc (model, path, iter, *data)

TreeSelectionFunc (selection, model, path, path_currently_selected, *data)

TreeViewColumnDropFunc (tree_view, column, prev_column, next_column, *data)

TreeViewMappingFunc (tree_view, path, *user_data)

TreeViewRowSeparatorFunc (model, iter, *data)

TreeViewSearchEqualFunc (model, column, key, iter, *search_data)

TreeViewSearchPositionFunc (tree_view, search_dialog, *user_data)

Details

Gtk.AccelGroupActivate(accel_group, acceleratable, keyval, modifier)
Parameters:
Return type:

bool

Gtk.AccelGroupFindFunc(key, closure, *data)
Parameters:
Return type:

bool

New in version 2.2.

Gtk.AccelMapForeach(data, accel_path, accel_key, accel_mods, changed)
Parameters:
Gtk.AssistantPageFunc(current_page, *data)
Parameters:
  • current_page (int) – The page number used to calculate the next page.

  • data (object or None) – user data.

Returns:

The next page number.

Return type:

int

A function used by Gtk.Assistant.set_forward_page_func() to know which is the next page given a current one. It’s called both for computing the next page when the user presses the “forward” button and for handling the behavior of the “last” button.

Gtk.BuilderConnectFunc(builder, object, signal_name, handler_name, connect_object, flags, *user_data)
Parameters:

This is the signature of a function used to connect signals. It is used by the Gtk.Builder.connect_signals() and Gtk.Builder.connect_signals_full() methods. It is mainly intended for interpreted language bindings, but could be useful where the programmer wants more control over the signal connection process. Note that this function can only be called once, subsequent calls will do nothing.

New in version 2.12.

Gtk.CalendarDetailFunc(calendar, year, month, day, *user_data)
Parameters:
Returns:

Newly allocated string with Pango markup with details for the specified day or None.

Return type:

str or None

This kind of functions provide Pango markup with detail information for the specified day. Examples for such details are holidays or appointments. The function returns None when no information is available.

New in version 2.14.

Gtk.Callback(widget, *data)
Parameters:

The type of the callback functions used for e.g. iterating over the children of a container, see Gtk.Container.foreach().

Gtk.CellAllocCallback(renderer, cell_area, cell_background, *data)
Parameters:
Returns:

True to stop iterating over cells.

Return type:

bool

The type of the callback functions used for iterating over the cell renderers and their allocated areas inside a Gtk.CellArea, see Gtk.CellArea.foreach_alloc().

Gtk.CellCallback(renderer, *data)
Parameters:
Returns:

True to stop iterating over cells.

Return type:

bool

The type of the callback functions used for iterating over the cell renderers of a Gtk.CellArea, see Gtk.CellArea.foreach().

Gtk.CellLayoutDataFunc(cell_layout, cell, tree_model, iter, *data)
Parameters:

A function which should set the value of cell_layout’s cell renderer(s) as appropriate.

Gtk.ClipboardClearFunc(clipboard, user_data_or_owner)
Parameters:
  • clipboard (Gtk.Clipboard) – the Gtk.Clipboard

  • user_data_or_owner (object or None) – the user_data argument passed to gtk_clipboard_set_with_data(), or the owner argument passed to gtk_clipboard_set_with_owner()

A function that will be called when the contents of the clipboard are changed or cleared. Once this has called, the user_data_or_owner argument will not be used again.

Gtk.ClipboardGetFunc(clipboard, selection_data, info, user_data_or_owner)
Parameters:
  • clipboard (Gtk.Clipboard) – the Gtk.Clipboard

  • selection_data (Gtk.SelectionData) – a Gtk.SelectionData argument in which the requested data should be stored.

  • info (int) – the info field corresponding to the requested target from the Gtk.TargetEntry array passed to gtk_clipboard_set_with_data() or gtk_clipboard_set_with_owner().

  • user_data_or_owner (object or None) – the user_data argument passed to gtk_clipboard_set_with_data(), or the owner argument passed to gtk_clipboard_set_with_owner()

A function that will be called to provide the contents of the selection. If multiple types of data were advertised, the requested type can be determined from the info parameter or by checking the target field of selection_data. If the data could successfully be converted into then it should be stored into the selection_data object by calling Gtk.SelectionData.set() (or related functions such as Gtk.SelectionData.set_text()). If no data is set, the requestor will be informed that the attempt to get the data failed.

Gtk.ClipboardImageReceivedFunc(clipboard, pixbuf, *data)
Parameters:

A function to be called when the results of Gtk.Clipboard.request_image() are received, or when the request fails.

New in version 2.6.

Gtk.ClipboardReceivedFunc(clipboard, selection_data, *data)
Parameters:

A function to be called when the results of Gtk.Clipboard.request_contents() are received, or when the request fails.

Gtk.ClipboardRichTextReceivedFunc(clipboard, format, text, length, *data)
Parameters:

A function to be called when the results of Gtk.Clipboard.request_rich_text() are received, or when the request fails.

New in version 2.10.

Gtk.ClipboardTargetsReceivedFunc(clipboard, atoms, *data)
Parameters:

A function to be called when the results of Gtk.Clipboard.request_targets() are received, or when the request fails.

New in version 2.4.

Gtk.ClipboardTextReceivedFunc(clipboard, text, *data)
Parameters:

A function to be called when the results of Gtk.Clipboard.request_text() are received, or when the request fails.

Gtk.ClipboardURIReceivedFunc(clipboard, uris, *data)
Parameters:

A function to be called when the results of Gtk.Clipboard.request_uris() are received, or when the request fails.

New in version 2.14.

Gtk.ColorSelectionChangePaletteFunc(colors)
Parameters:

colors ([Gdk.Color]) – Array of colors

Deprecated since version 3.4.

Gtk.ColorSelectionChangePaletteWithScreenFunc(screen, colors)
Parameters:

New in version 2.2.

Deprecated since version 3.4.

Gtk.EntryCompletionMatchFunc(completion, key, iter, *user_data)
Parameters:
Returns:

True if iter should be displayed as a possible completion for key

Return type:

bool

A function which decides whether the row indicated by iter matches a given key, and should be displayed as a possible completion for key. Note that key is normalized and case-folded (see GLib.utf8_normalize() and GLib.utf8_casefold()). If this is not appropriate, match functions have access to the unmodified key via gtk_entry_get_text (GTK_ENTRY (gtk_entry_completion_get_entry ())).

Gtk.FileFilterFunc(filter_info, *data)
Parameters:
Returns:

True if the file should be displayed

Return type:

bool

The type of function that is used with custom filters, see Gtk.FileFilter.add_custom().

Gtk.FlowBoxCreateWidgetFunc(item, *user_data)
Parameters:
Returns:

a Gtk.Widget that represents item

Return type:

Gtk.Widget

Called for flow boxes that are bound to a Gio.ListModel with Gtk.FlowBox.bind_model() for each item that gets added to the model.

New in version 3.18.

Gtk.FlowBoxFilterFunc(child, *user_data)
Parameters:
Returns:

True if the row should be visible, False otherwise

Return type:

bool

A function that will be called whenrever a child changes or is added. It lets you control if the child should be visible or not.

New in version 3.12.

Gtk.FlowBoxForeachFunc(box, child, *user_data)
Parameters:

A function used by Gtk.FlowBox.selected_foreach(). It will be called on every selected child of the box.

New in version 3.12.

Gtk.FlowBoxSortFunc(child1, child2, *user_data)
Parameters:
Returns:

< 0 if child1 should be before child2, 0 if the are equal, and > 0 otherwise

Return type:

int

A function to compare two children to determine which should come first.

New in version 3.12.

Gtk.FontFilterFunc(family, face, *data)
Parameters:
Returns:

True if the font should be displayed

Return type:

bool

The type of function that is used for deciding what fonts get shown in a Gtk.FontChooser. See Gtk.FontChooser.set_filter_func().

Gtk.IconViewForeachFunc(icon_view, path, *data)
Parameters:

A function used by Gtk.IconView.selected_foreach() to map all selected rows. It will be called on every selected row in the view.

Gtk.KeySnoopFunc(grab_widget, event, *func_data)
Parameters:
  • grab_widget (Gtk.Widget) – the widget to which the event will be delivered

  • event (Gdk.EventKey) – the key event

  • func_data (object or None) – data supplied to gtk_key_snooper_install()

Returns:

True to stop further processing of event, False to continue.

Return type:

int

Key snooper functions are called before normal event delivery. They can be used to implement custom key event handling.

Gtk.ListBoxCreateWidgetFunc(item, *user_data)
Parameters:
  • item (GObject.Object) – the item from the model for which to create a widget for

  • user_data (object or None) – user data

Returns:

a Gtk.Widget that represents item

Return type:

Gtk.Widget

Called for list boxes that are bound to a Gio.ListModel with Gtk.ListBox.bind_model() for each item that gets added to the model.

Versions of GTK+ prior to 3.18 called Gtk.Widget.show_all() on the rows created by the Gtk.ListBoxCreateWidgetFunc, but this forced all widgets inside the row to be shown, and is no longer the case. Applications should be updated to show the desired row widgets.

New in version 3.16.

Gtk.ListBoxFilterFunc(row, *user_data)
Parameters:
Returns:

True if the row should be visible, False otherwise

Return type:

bool

Will be called whenever the row changes or is added and lets you control if the row should be visible or not.

New in version 3.10.

Gtk.ListBoxForeachFunc(box, row, *user_data)
Parameters:

A function used by Gtk.ListBox.selected_foreach(). It will be called on every selected child of the box.

New in version 3.14.

Gtk.ListBoxSortFunc(row1, row2, *user_data)
Parameters:
Returns:

< 0 if row1 should be before row2, 0 if they are equal and > 0 otherwise

Return type:

int

Compare two rows to determine which should be first.

New in version 3.10.

Gtk.ListBoxUpdateHeaderFunc(row, before, *user_data)
Parameters:

Whenever row changes or which row is before row changes this is called, which lets you update the header on row. You may remove or set a new one via Gtk.ListBoxRow.set_header() or just change the state of the current header widget.

New in version 3.10.

Gtk.MenuDetachFunc(attach_widget, menu)
Parameters:

A user function supplied when calling Gtk.Menu.attach_to_widget() which will be called when the menu is later detached from the widget.

Gtk.MenuPositionFunc(menu, x, y, *user_data)
Parameters:
  • menu (Gtk.Menu) – a Gtk.Menu.

  • x (int) – address of the int representing the horizontal position where the menu shall be drawn.

  • y (int) – address of the int representing the vertical position where the menu shall be drawn. This is an output parameter.

  • user_data (object or None) – the data supplied by the user in the Gtk.Menu.popup() data parameter.

Returns:

x:

address of the int representing the horizontal position where the menu shall be drawn.

y:

address of the int representing the vertical position where the menu shall be drawn. This is an output parameter.

push_in:

This parameter controls how menus placed outside the monitor are handled. If this is set to True and part of the menu is outside the monitor then GTK+ pushes the window into the visible area, effectively modifying the popup position. Note that moving and possibly resizing the menu around will alter the scroll position to keep the menu items “in place”, i.e. at the same monitor position they would have been without resizing. In practice, this behavior is only useful for combobox popups or option menus and cannot be used to simply confine a menu to monitor boundaries. In that case, changing the scroll offset is not desirable.

Return type:

(x: int, y: int, push_in: bool)

A user function supplied when calling Gtk.Menu.popup() which controls the positioning of the menu when it is displayed. The function sets the x and y parameters to the coordinates where the menu is to be drawn. To make the menu appear on a different monitor than the mouse pointer, Gtk.Menu.set_monitor() must be called.

Gtk.ModuleDisplayInitFunc(display)
Parameters:

display (Gdk.Display) – an open Gdk.Display

A multihead-aware GTK+ module may have a gtk_module_display_init() function with this prototype. GTK+ calls this function for each opened display.

New in version 2.2.

Gtk.ModuleInitFunc(argv)
Parameters:

argv ([str] or None) – GTK+ always passes None for this argument

Each GTK+ module must have a function gtk_module_init() with this prototype. This function is called after loading the module.

Gtk.PageSetupDoneFunc(page_setup, *data)
Parameters:

The type of function that is passed to Gtk.print_run_page_setup_dialog_async().

This function will be called when the page setup dialog is dismissed, and also serves as destroy notify for data.

Gtk.PrintSettingsFunc(key, value, *user_data)
Parameters:
Gtk.RcPropertyParser(pspec, rc_string, property_value)
Parameters:
Return type:

bool

Gtk.RecentFilterFunc(filter_info, *user_data)
Parameters:
Returns:

True if the file should be displayed

Return type:

bool

The type of function that is used with custom filters, see Gtk.RecentFilter.add_custom().

Gtk.RecentSortFunc(a, b, *user_data)
Parameters:
Return type:

int

Gtk.StylePropertyParser(string, value)
Parameters:
Return type:

bool

Gtk.TextBufferDeserializeFunc(register_buffer, content_buffer, iter, data, create_tags, *user_data)
Parameters:
Returns:

True on success, False otherwise

Return type:

bool

A function that is called to deserialize rich text that has been serialized with Gtk.TextBuffer.serialize(), and insert it at iter.

Gtk.TextBufferSerializeFunc(register_buffer, content_buffer, start, end, *user_data)
Parameters:
Returns:

a newly-allocated array of guint8 which contains the serialized data, or None if an error occurred

Return type:

bytes or None

A function that is called to serialize the content of a text buffer. It must return the serialized form of the content.

Gtk.TextCharPredicate(ch, *user_data)
Parameters:
Return type:

bool

Gtk.TextTagTableForeach(tag, *data)
Parameters:
Gtk.TickCallback(widget, frame_clock, *user_data)
Parameters:
Returns:

GLib.SOURCE_CONTINUE if the tick callback should continue to be called, GLib.SOURCE_REMOVE if the tick callback should be removed.

Return type:

bool

Callback type for adding a function to update animations. See Gtk.Widget.add_tick_callback().

New in version 3.8.

Gtk.TranslateFunc(path, *func_data)
Parameters:
Returns:

the translated message

Return type:

str

The function used to translate messages in e.g. Gtk.IconFactory and Gtk.ActionGroup.

Deprecated since version 3.10.

Gtk.TreeCellDataFunc(tree_column, cell, tree_model, iter, *data)
Parameters:

A function to set the properties of a cell instead of just using the straight mapping between the cell and the model. This is useful for customizing the cell renderer. For example, a function might get an integer from the tree_model, and render it to the “text” attribute of “cell” by converting it to its written equivalent. This is set by calling Gtk.TreeViewColumn.set_cell_data_func()

Gtk.TreeDestroyCountFunc(tree_view, path, children, *user_data)
Parameters:
Gtk.TreeIterCompareFunc(model, a, b, *user_data)
Parameters:
Returns:

a negative integer, zero or a positive integer depending on whether a sorts before, with or after b

Return type:

int

A Gtk.TreeIterCompareFunc should return a negative integer, zero, or a positive integer if a sorts before b, a sorts with b, or a sorts after b respectively. If two iters compare as equal, their order in the sorted model is undefined. In order to ensure that the Gtk.TreeSortable behaves as expected, the Gtk.TreeIterCompareFunc must define a partial order on the model, i.e. it must be reflexive, antisymmetric and transitive.

For example, if model is a product catalogue, then a compare function for the “price” column could be one which returns price_of(@a) - price_of(@b).

Gtk.TreeModelFilterModifyFunc(model, iter, column, *data)
Parameters:
Returns:

A GObject.Value which is already initialized for with the correct type for the column column.

Return type:

value: GObject.Value

A function which calculates display values from raw values in the model. It must fill value with the display value for the column column in the row indicated by iter.

Since this function is called for each data access, it’s not a particularly efficient operation.

Gtk.TreeModelFilterVisibleFunc(model, iter, *data)
Parameters:
Returns:

Whether the row indicated by iter is visible.

Return type:

bool

A function which decides whether the row indicated by iter is visible.

Gtk.TreeModelForeachFunc(model, path, iter, *data)
Parameters:
Returns:

True to stop iterating, False to continue

Return type:

bool

Type of the callback passed to Gtk.TreeModel.foreach() to iterate over the rows in a tree model.

Gtk.TreeSelectionForeachFunc(model, path, iter, *data)
Parameters:

A function used by Gtk.TreeSelection.selected_foreach() to map all selected rows. It will be called on every selected row in the view.

Gtk.TreeSelectionFunc(selection, model, path, path_currently_selected, *data)
Parameters:
Returns:

True, if the selection state of the row can be toggled

Return type:

bool

A function used by Gtk.TreeSelection.set_select_function() to filter whether or not a row may be selected. It is called whenever a row’s state might change. A return value of True indicates to selection that it is okay to change the selection.

Gtk.TreeViewColumnDropFunc(tree_view, column, prev_column, next_column, *data)
Parameters:
Returns:

True, if column can be dropped in this spot

Return type:

bool

Function type for determining whether column can be dropped in a particular spot (as determined by prev_column and next_column). In left to right locales, prev_column is on the left of the potential drop spot, and next_column is on the right. In right to left mode, this is reversed. This function should return True if the spot is a valid drop spot. Please note that returning True does not actually indicate that the column drop was made, but is meant only to indicate a possible drop spot to the user.

Gtk.TreeViewMappingFunc(tree_view, path, *user_data)
Parameters:

Function used for Gtk.TreeView.map_expanded_rows().

Gtk.TreeViewRowSeparatorFunc(model, iter, *data)
Parameters:
Returns:

True if the row is a separator

Return type:

bool

Function type for determining whether the row pointed to by iter should be rendered as a separator. A common way to implement this is to have a boolean column in the model, whose values the Gtk.TreeViewRowSeparatorFunc returns.

Gtk.TreeViewSearchEqualFunc(model, column, key, iter, *search_data)
Parameters:
Returns:

False if the row matches, True otherwise.

Return type:

bool

A function used for checking whether a row in model matches a search key string entered by the user. Note the return value is reversed from what you would normally expect, though it has some similarity to strcmp() returning 0 for equal strings.

Gtk.TreeViewSearchPositionFunc(tree_view, search_dialog, *user_data)
Parameters: