EntryCompletion#
Deprecated since version 4.10: Please do not use it in newly written code
Superclasses: Object
Implemented Interfaces: Buildable, CellLayout
GtkEntryCompletion is an auxiliary object to provide completion functionality
for GtkEntry.
It implements the CellLayout interface, to allow the user
to add extra cells to the GtkTreeView with completion matches.
“Completion functionality” means that when the user modifies the text
in the entry, GtkEntryCompletion checks which rows in the model match
the current content of the entry, and displays a list of matches.
By default, the matching is done by comparing the entry text
case-insensitively against the text column of the model (see
set_text_column), but this can be overridden
with a custom match function (see set_match_func).
When the user selects a completion, the content of the entry is
updated. By default, the content of the entry is replaced by the
text column of the model, but this can be overridden by connecting
to the match_selected signal and updating the
entry in the signal handler. Note that you should return True from
the signal handler to suppress the default behaviour.
To add completion functionality to an entry, use
set_completion.
GtkEntryCompletion uses a TreeModelFilter model to
represent the subset of the entire model that is currently matching.
While the GtkEntryCompletion signals
match_selected and
cursor_on_match take the original model
and an iter pointing to that model as arguments, other callbacks and
signals (such as GtkCellLayoutDataFunc or
apply_attributes)
will generally take the filter model as argument. As long as you are
only calling get, this will make no difference to
you. If for some reason, you need the original model, use
get_model. Don’t forget to use
convert_iter_to_child_iter to obtain a
matching iter.
Constructors#
- class EntryCompletion
- classmethod new() EntryCompletion#
Creates a new
GtkEntryCompletionobject.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- classmethod new_with_area(area: CellArea) EntryCompletion#
Creates a new
GtkEntryCompletionobject using the specifiedarea.The
GtkCellAreais used to layout cells in the underlyingGtkTreeViewColumnfor the drop-down menu.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
area – the
GtkCellAreaused to layout cells
Methods#
- class EntryCompletion
- complete() None#
Requests a completion operation, or in other words a refiltering of the current list with completions, using the current key.
The completion list view will be updated accordingly.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- compute_prefix(key: str) str | None#
Computes the common prefix that is shared by all rows in
completionthat start withkey.If no row matches
key,Nonewill be returned. Note that a text column must have been set for this function to work, seeset_text_columnfor details.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
key – The text to complete for
- get_completion_prefix() str | None#
Get the original text entered by the user that triggered the completion or
Noneif there’s no completion ongoing.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- get_entry() Widget#
Gets the entry
completionhas been attached to.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- get_inline_completion() bool#
Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- get_inline_selection() bool#
Returns
Trueif inline-selection mode is turned on.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- get_minimum_key_length() int#
Returns the minimum key length as set for
completion.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- get_model() TreeModel | None#
Returns the model the
GtkEntryCompletionis using as data source.Returns
Noneif the model is unset.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- get_popup_completion() bool#
Returns whether the completions should be presented in a popup window.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- get_popup_set_width() bool#
Returns whether the completion popup window will be resized to the width of the entry.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- get_popup_single_match() bool#
Returns whether the completion popup window will appear even if there is only a single match.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- get_text_column() int#
Returns the column in the model of
completionto get strings from.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- insert_prefix() None#
Requests a prefix insertion.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- set_inline_completion(inline_completion: bool) None#
Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
inline_completion –
Trueto do inline completion
- set_inline_selection(inline_selection: bool) None#
Sets whether it is possible to cycle through the possible completions inside the entry.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
inline_selection –
Trueto do inline selection
- set_match_func(func: Callable[[EntryCompletion, str, TreeIter, Any], bool], func_data: Any = None) None#
Sets the match function for
completionto befunc.The match function is used to determine if a row should or should not be in the completion list.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
func – the
GtkEntryCompletionMatchFunc to usefunc_data – user data for
func
- set_minimum_key_length(length: int) None#
Requires the length of the search key for
completionto be at leastlength.This is useful for long lists, where completing using a small key takes a lot of time and will come up with meaningless results anyway (ie, a too large dataset).
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
length – the minimum length of the key in order to start completing
- set_model(model: TreeModel | None = None) None#
Sets the model for a
GtkEntryCompletion.If
completionalready has a model set, it will remove it before setting the new model. If model isNone, then it will unset the model.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
model – the
GtkTreeModel
- set_popup_completion(popup_completion: bool) None#
Sets whether the completions should be presented in a popup window.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
popup_completion –
Trueto do popup completion
- set_popup_set_width(popup_set_width: bool) None#
Sets whether the completion popup window will be resized to be the same width as the entry.
Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
popup_set_width –
Trueto make the width of the popup the same as the entry
- set_popup_single_match(popup_single_match: bool) None#
Sets whether the completion popup window will appear even if there is only a single match.
You may want to set this to
Falseif you are usinginline_completion.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
popup_single_match –
Trueif the popup should appear even for a single match
- set_text_column(column: int) None#
Convenience function for setting up the most used case of this code: a completion list with just strings.
This function will set up
completionto have a list displaying all (and just) strings in the completion list, and to get those strings fromcolumnin the model ofcompletion.This functions creates and adds a
GtkCellRendererTextfor the selected column. If you need to set the text column, but don’t want the cell renderer, useset()to set thetext_columnproperty directly.Deprecated since version 4.10: GtkEntryCompletion will be removed in GTK 5.
- Parameters:
column – the column in the model of
completionto get strings from
Properties#
- class EntryCompletion
Signals#
- class EntryCompletion.signals
- cursor_on_match(model: TreeModel, iter: TreeIter) bool#
The type of the None singleton.
- Parameters:
model – the
GtkTreeModelcontaining the matchesiter – a
GtkTreeIterpositioned at the selected match
- insert_prefix(prefix: str) bool#
The type of the None singleton.
- Parameters:
prefix – the common prefix of all possible completions