Callbacks

AssistantPageFunc (current_page, *data)

CellAllocCallback (renderer, cell_area, cell_background, *data)

CellCallback (renderer, *data)

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

CustomAllocateFunc (widget, width, height, baseline)

CustomFilterFunc (item, *user_data)

CustomMeasureFunc (widget, orientation, for_size)

CustomRequestModeFunc (widget)

DrawingAreaDrawFunc (drawing_area, cr, width, height, *user_data)

EntryCompletionMatchFunc (completion, key, iter, *user_data)

ExpressionNotify (*user_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)

ListBoxCreateWidgetFunc (item, *user_data)

ListBoxFilterFunc (row, *user_data)

ListBoxForeachFunc (box, row, *user_data)

ListBoxSortFunc (row1, row2, *user_data)

ListBoxUpdateHeaderFunc (row, before, *user_data)

MapListModelMapFunc (item, *user_data)

MenuButtonCreatePopupFunc (menu_button, *user_data)

PageSetupDoneFunc (page_setup, *data)

PrintJobCompleteFunc (print_job, user_data, error)

PrintSettingsFunc (key, value, *user_data)

PrinterFunc (printer, *data)

ScaleFormatValueFunc (scale, value, *user_data)

ShortcutFunc (widget, args, *user_data)

TextCharPredicate (ch, *user_data)

TextTagTableForeach (tag, *data)

TickCallback (widget, frame_clock, *user_data)

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

TreeIterCompareFunc (model, a, b, *user_data)

TreeListModelCreateModelFunc (item, *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)

WidgetActionActivateFunc (widget, action_name, parameter)

Details

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

Type of callback used to calculate the next page in a GtkAssistant.

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.

See [method`Gtk`.Assistant.set_forward_page_func].

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 GtkCellArea, 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 GtkCellArea, 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.CustomAllocateFunc(widget, width, height, baseline)
Parameters:
  • widget (Gtk.Widget) – the widget to allocate

  • width (int) – the new width of the widget

  • height (int) – the new height of the widget

  • baseline (int) – the new baseline of the widget, or -1

A function to be used by GtkCustomLayout to allocate a widget.

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

True to keep the item around

Return type:

bool

User function that is called to determine if the item should be matched.

If the filter matches the item, this function must return True. If the item should be filtered out, False must be returned.

Gtk.CustomMeasureFunc(widget, orientation, for_size)
Parameters:
  • widget (Gtk.Widget) – the widget to be measured

  • orientation (Gtk.Orientation) – the direction to be measured

  • for_size (int) – the size to be measured for

Returns:

minimum:

the measured minimum size of the widget

natural:

the measured natural size of the widget

minimum_baseline:

the measured minimum baseline of the widget

natural_baseline:

the measured natural baseline of the widget

Return type:

(minimum: int, natural: int, minimum_baseline: int, natural_baseline: int)

A function to be used by GtkCustomLayout to measure a widget.

Gtk.CustomRequestModeFunc(widget)
Parameters:

widget (Gtk.Widget) – the widget to be queried

Returns:

the size request mode

Return type:

Gtk.SizeRequestMode

Queries a widget for its preferred size request mode.

Gtk.DrawingAreaDrawFunc(drawing_area, cr, width, height, *user_data)
Parameters:
  • drawing_area (Gtk.DrawingArea) – the GtkDrawingArea to redraw

  • cr (cairo.Context) – the context to draw to

  • width (int) – the actual width of the contents. This value will be at least as wide as Gtk.DrawingArea :width.

  • height (int) – the actual height of the contents. This value will be at least as wide as Gtk.DrawingArea :height.

  • user_data (object or None) – user data

Whenever drawing_area needs to redraw, this function will be called.

This function should exclusively redraw the contents of the drawing area and must not call any widget functions that cause changes.

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_editable_get_text (GTK_EDITABLE (gtk_entry_completion_get_entry ())).

Gtk.ExpressionNotify(*user_data)
Parameters:

user_data (object or None) – data passed to Gtk.Expression.watch()

Callback called by Gtk.Expression.watch() when the expression value changes.

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

a GtkWidget that represents item

Return type:

Gtk.Widget

Called for flow boxes that are bound to a GListModel.

This function is called for each item that gets added to the model.

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 whenever a child changes or is added.

It lets you control if the child should be visible or not.

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.

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

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

Return type:

int

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

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 GtkFontChooser.

See [method`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.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 GtkWidget that represents item

Return type:

Gtk.Widget

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

If the widget returned is not a Gtk.ListBoxRow widget, then the widget will be inserted as the child of an intermediate Gtk.ListBoxRow.

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.

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.

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.

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 [method`Gtk`.ListBoxRow.set_header] or just change the state of the current header widget.

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

The item to map to

Return type:

GObject.Object

User function that is called to map an item of the original model to an item expected by the map model.

The returned items must conform to the item type of the model they are used with.

Gtk.MenuButtonCreatePopupFunc(menu_button, *user_data)
Parameters:

User-provided callback function to create a popup for a GtkMenuButton on demand.

This function is called when the popup of menu_button is shown, but none has been provided via [method`Gtk`.MenuButton.set_popover] or [method`Gtk`.MenuButton.set_menu_model].

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.PrintJobCompleteFunc(print_job, user_data, error)
Parameters:

The type of callback that is passed to Gtk.PrintJob.send().

It is called when the print job has been completely sent.

Gtk.PrintSettingsFunc(key, value, *user_data)
Parameters:
Gtk.PrinterFunc(printer, *data)
Parameters:
Returns:

True to stop the enumeration, False to continue

Return type:

bool

The type of function passed to Gtk.enumerate_printers().

Note that you need to ref printer, if you want to keep a reference to it after the function has returned.

Gtk.ScaleFormatValueFunc(scale, value, *user_data)
Parameters:
  • scale (Gtk.Scale) – The GtkScale

  • value (float) – The numeric value to format

  • user_data (object or None) – user data

Returns:

A newly allocated string describing a textual representation of the given numerical value.

Return type:

str

Gtk.ShortcutFunc(widget, args, *user_data)
Parameters:
  • widget (Gtk.Widget) – The widget passed to the activation

  • args (GLib.Variant or None) – The arguments passed to the activation

  • user_data (object or None) – The user data provided when activating the action

Returns:

True if the action was successful.

Return type:

bool

Prototype for shortcuts based on user callbacks.

Gtk.TextCharPredicate(ch, *user_data)
Parameters:
  • ch (str) – a Unicode code point

  • user_data (object or None) – data passed to the callback

Returns:

True if the predicate is satisfied, and the iteration should stop, and False otherwise

Return type:

bool

The predicate function used by Gtk.TextIter.forward_find_char() and Gtk.TextIter.backward_find_char().

Gtk.TextTagTableForeach(tag, *data)
Parameters:

A function used with Gtk.TextTagTable.foreach(), to iterate over every GtkTextTag inside a GtkTextTagTable.

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().

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 function 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.

See also: Gtk.TreeViewColumn.set_cell_data_func()

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 GtkTreeSortable 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.TreeListModelCreateModelFunc(item, *user_data)
Parameters:
  • item (GObject.Object) – The item that is being expanded

  • user_data (object or None) – User data passed when registering the function

Returns:

The model tracking the children of item or None if item can never have children

Return type:

Gio.ListModel or None

Prototype of the function called to create new child models when Gtk.TreeListRow.set_expanded() is called.

This function can return None to indicate that item is guaranteed to be a leaf node and will never have children. If it does not have children but may get children later, it should return an empty model that is filled once children arrive.

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

A GValue 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 GtkTreeViewRowSeparatorFunc 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.WidgetActionActivateFunc(widget, action_name, parameter)
Parameters:
  • widget (Gtk.Widget) – the widget to which the action belongs

  • action_name (str) – the action name

  • parameter (GLib.Variant or None) – parameter for activation

The type of the callback functions used for activating actions installed with Gtk.WidgetClass.install_action().

The parameter must match the parameter_type of the action.