Gtk.EntryCompletion¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when a match from the cursor is on a match of the list. |
|
Emitted when the inline autocompletion is triggered. |
|
Emitted when a match from the list is selected. |
|
Emitted when the filter model has zero number of rows in completion_complete method. |
Fields¶
- Inherited:
Class Details¶
- class Gtk.EntryCompletion(**kwargs)¶
- Bases:
- Abstract:
No
GtkEntryCompletion
is an auxiliary object to provide completion functionality forGtkEntry
.It implements the [iface`Gtk`.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 [method`Gtk`.EntryCompletion.set_text_column]), but this can be overridden with a custom match function (see [method`Gtk`.EntryCompletion.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 [signal`Gtk`.EntryCompletion::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 [method`Gtk`.Entry.set_completion].
GtkEntryCompletion
uses a [class`Gtk`.TreeModelFilter] model to represent the subset of the entire model that is currently matching. While theGtkEntryCompletion
signals [signal`Gtk`.EntryCompletion::match-selected] and [signal`Gtk`.EntryCompletion::cursor-on-match] take the original model and an iter pointing to that model as arguments, other callbacks and signals (such asGtkCellLayoutDataFunc
or [signal`Gtk`.CellArea::apply-attributes)] will generally take the filter model as argument. As long as you are only calling [method`Gtk`.TreeModel.get], this will make no difference to you. If for some reason, you need the original model, use [method`Gtk`.TreeModelFilter.get_model]. Don’t forget to use [method`Gtk`.TreeModelFilter.convert_iter_to_child_iter] to obtain a matching iter.Deprecated since version 4.10.
- classmethod new()[source]¶
- Returns:
A newly created
GtkEntryCompletion
object- Return type:
Creates a new
GtkEntryCompletion
object.Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- classmethod new_with_area(area)[source]¶
- Parameters:
area (
Gtk.CellArea
) – theGtkCellArea
used to layout cells- Returns:
A newly created
GtkEntryCompletion
object- Return type:
Creates a new
GtkEntryCompletion
object using the specified area.The
GtkCellArea
is used to layout cells in the underlyingGtkTreeViewColumn
for the drop-down menu.Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- complete()[source]¶
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:
Gtk.EntryCompletion
will be removed in GTK 5.
- compute_prefix(key)[source]¶
- Parameters:
key (
str
) – The text to complete for- Returns:
The common prefix all rows starting with key
- Return type:
Computes the common prefix that is shared by all rows in self that start with key.
If no row matches key,
None
will be returned. Note that a text column must have been set for this function to work, see [method`Gtk`.EntryCompletion.set_text_column] for details.Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- get_completion_prefix()[source]¶
-
Get the original text entered by the user that triggered the completion or
None
if there’s no completion ongoing.Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- get_entry()[source]¶
- Returns:
The entry self has been attached to
- Return type:
Gets the entry self has been attached to.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- get_inline_completion()[source]¶
-
Returns whether the common prefix of the possible completions should be automatically inserted in the entry.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- get_inline_selection()[source]¶
-
Returns
True
if inline-selection mode is turned on.Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- get_minimum_key_length()[source]¶
- Returns:
The currently used minimum key length
- Return type:
Returns the minimum key length as set for self.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- get_model()[source]¶
- Returns:
A
GtkTreeModel
- Return type:
Returns the model the
GtkEntryCompletion
is using as data source.Returns
None
if the model is unset.Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- get_popup_completion()[source]¶
-
Returns whether the completions should be presented in a popup window.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- get_popup_set_width()[source]¶
-
Returns whether the completion popup window will be resized to the width of the entry.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- get_popup_single_match()[source]¶
-
Returns whether the completion popup window will appear even if there is only a single match.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- get_text_column()[source]¶
- Returns:
the column containing the strings
- Return type:
Returns the column in the model of self to get strings from.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- insert_prefix()[source]¶
Requests a prefix insertion.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- set_inline_completion(inline_completion)[source]¶
-
Sets whether the common prefix of the possible completions should be automatically inserted in the entry.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- set_inline_selection(inline_selection)[source]¶
-
Sets whether it is possible to cycle through the possible completions inside the entry.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- set_match_func(func, *func_data)[source]¶
- Parameters:
func (
Gtk.EntryCompletionMatchFunc
) – the ``GtkEntryCompletion``MatchFunc to use
Sets the match function for self to be func.
The match function is used to determine if a row should or should not be in the completion list.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- set_minimum_key_length(length)[source]¶
- Parameters:
length (
int
) – the minimum length of the key in order to start completing
Requires the length of the search key for self to be at least length.
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:
Gtk.EntryCompletion
will be removed in GTK 5.
- set_model(model)[source]¶
- Parameters:
model (
Gtk.TreeModel
orNone
) – theGtkTreeModel
Sets the model for a
GtkEntryCompletion
.If self already has a model set, it will remove it before setting the new model. If model is
None
, then it will unset the model.Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- set_popup_completion(popup_completion)[source]¶
-
Sets whether the completions should be presented in a popup window.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- set_popup_set_width(popup_set_width)[source]¶
-
Sets whether the completion popup window will be resized to be the same width as the entry.
Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- set_popup_single_match(popup_single_match)[source]¶
-
Sets whether the completion popup window will appear even if there is only a single match.
You may want to set this to
False
if you are using [property`Gtk`.EntryCompletion:inline-completion].Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
- set_text_column(column)[source]¶
- Parameters:
column (
int
) – the column in the model of self to get strings from
Convenience function for setting up the most used case of this code: a completion list with just strings.
This function will set up self to have a list displaying all (and just) strings in the completion list, and to get those strings from column in the model of self.
This functions creates and adds a
GtkCellRendererText
for the selected column. If you need to set the text column, but don’t want the cell renderer, use g_object_set() to set the [property`Gtk`.EntryCompletion:text-column] property directly.Deprecated since version 4.10:
Gtk.EntryCompletion
will be removed in GTK 5.
Signal Details¶
- Gtk.EntryCompletion.signals.cursor_on_match(entry_completion, model, iter)¶
- Signal Name:
cursor-on-match
- Flags:
- Parameters:
entry_completion (
Gtk.EntryCompletion
) – The object which received the signalmodel (
Gtk.TreeModel
) – theGtkTreeModel
containing the matchesiter (
Gtk.TreeIter
) – aGtkTreeIter
positioned at the selected match
- Returns:
True
if the signal has been handled- Return type:
Emitted when a match from the cursor is on a match of the list.
The default behaviour is to replace the contents of the entry with the contents of the text column in the row pointed to by iter.
Note that model is the model that was passed to [method`Gtk`.EntryCompletion.set_model].
- Gtk.EntryCompletion.signals.insert_prefix(entry_completion, prefix)¶
- Signal Name:
insert-prefix
- Flags:
- Parameters:
entry_completion (
Gtk.EntryCompletion
) – The object which received the signalprefix (
str
) – the common prefix of all possible completions
- Returns:
True
if the signal has been handled- Return type:
Emitted when the inline autocompletion is triggered.
The default behaviour is to make the entry display the whole prefix and select the newly inserted part.
Applications may connect to this signal in order to insert only a smaller part of the prefix into the entry - e.g. the entry used in the
GtkFileChooser
inserts only the part of the prefix up to the next ‘/’.
- Gtk.EntryCompletion.signals.match_selected(entry_completion, model, iter)¶
- Signal Name:
match-selected
- Flags:
- Parameters:
entry_completion (
Gtk.EntryCompletion
) – The object which received the signalmodel (
Gtk.TreeModel
) – theGtkTreeModel
containing the matchesiter (
Gtk.TreeIter
) – aGtkTreeIter
positioned at the selected match
- Returns:
True
if the signal has been handled- Return type:
Emitted when a match from the list is selected.
The default behaviour is to replace the contents of the entry with the contents of the text column in the row pointed to by iter.
Note that model is the model that was passed to [method`Gtk`.EntryCompletion.set_model].
- Gtk.EntryCompletion.signals.no_matches(entry_completion)¶
- Signal Name:
no-matches
- Flags:
- Parameters:
entry_completion (
Gtk.EntryCompletion
) – The object which received the signal
Emitted when the filter model has zero number of rows in completion_complete method.
In other words when
GtkEntryCompletion
is out of suggestions.
Property Details¶
- Gtk.EntryCompletion.props.cell_area¶
- Name:
cell-area
- Type:
- Default Value:
- Flags:
The
GtkCellArea
used to layout cell renderers in the treeview column.If no area is specified when creating the entry completion with [ctor`Gtk`.EntryCompletion.new_with_area], a horizontally oriented [class`Gtk`.CellAreaBox] will be used.
- Gtk.EntryCompletion.props.inline_completion¶
- Name:
inline-completion
- Type:
- Default Value:
- Flags:
Determines whether the common prefix of the possible completions should be inserted automatically in the entry.
Note that this requires text-column to be set, even if you are using a custom match function.
- Gtk.EntryCompletion.props.inline_selection¶
- Name:
inline-selection
- Type:
- Default Value:
- Flags:
Determines whether the possible completions on the popup will appear in the entry as you navigate through them.
- Gtk.EntryCompletion.props.minimum_key_length¶
- Name:
minimum-key-length
- Type:
- Default Value:
1
- Flags:
- Gtk.EntryCompletion.props.model¶
- Name:
model
- Type:
- Default Value:
- Flags:
- Gtk.EntryCompletion.props.popup_completion¶
- Name:
popup-completion
- Type:
- Default Value:
- Flags:
Determines whether the possible completions should be shown in a popup window.
- Gtk.EntryCompletion.props.popup_set_width¶
- Name:
popup-set-width
- Type:
- Default Value:
- Flags:
Determines whether the completions popup window will be resized to the width of the entry.