Gtk.EntryCompletion¶
| Subclasses: | None | 
|---|
Methods¶
| Inherited: | GObject.Object (37), Gtk.Buildable (10), Gtk.CellLayout (9) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| class | new() | 
| class | new_with_area(area) | 
| complete() | |
| compute_prefix(key) | |
| delete_action(index_) | |
| get_completion_prefix() | |
| get_entry() | |
| get_inline_completion() | |
| get_inline_selection() | |
| get_minimum_key_length() | |
| get_model() | |
| get_popup_completion() | |
| get_popup_set_width() | |
| get_popup_single_match() | |
| get_text_column() | |
| insert_action_markup(index_, markup) | |
| insert_action_text(index_, text) | |
| insert_prefix() | |
| set_inline_completion(inline_completion) | |
| set_inline_selection(inline_selection) | |
| set_match_func(func, *func_data) | |
| set_minimum_key_length(length) | |
| set_model(model) | |
| set_popup_completion(popup_completion) | |
| set_popup_set_width(popup_set_width) | |
| set_popup_single_match(popup_single_match) | |
| set_text_column(column) | 
Virtual Methods¶
| Inherited: | GObject.Object (7), Gtk.Buildable (10), Gtk.CellLayout (9) | 
|---|
| do_action_activated(index_) | |
| do_cursor_on_match(model, iter) | |
| do_insert_prefix(prefix) | |
| do_match_selected(model, iter) | |
| do_no_matches() | 
Properties¶
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| cell-area | Gtk.CellArea | r/w/co | The Gtk.CellAreaused to layout cells | 
| inline-completion | bool | r/w/en | Whether the common prefix should be inserted automatically | 
| inline-selection | bool | r/w/en | Your description here | 
| minimum-key-length | int | r/w/en | Minimum length of the search key in order to look up matches | 
| model | Gtk.TreeModel | r/w | The model to find matches in | 
| popup-completion | bool | r/w/en | Whether the completions should be shown in a popup window | 
| popup-set-width | bool | r/w/en | If True, the popup window will have the same size as the entry | 
| popup-single-match | bool | r/w/en | If True, the popup window will appear for a single match. | 
| text-column | int | r/w | The column of the model containing the strings. | 
Signals¶
| Inherited: | GObject.Object (1) | 
|---|
| Name | Short Description | 
|---|---|
| action-activated | Gets emitted when an action is activated. | 
| cursor-on-match | Gets emitted when a match from the cursor is on a match of the list. | 
| insert-prefix | Gets emitted when the inline autocompletion is triggered. | 
| match-selected | Gets emitted when a match from the list is selected. | 
| no-matches | Gets emitted when the filter model has zero number of rows in completion_complete method. | 
Class Details¶
- 
class Gtk.EntryCompletion(**kwargs)¶
- Bases: - GObject.Object,- Gtk.Buildable,- Gtk.CellLayout- Abstract: - No - Structure: - Gtk.EntryCompletionClass- Gtk.EntryCompletionis an auxiliary object to be used in conjunction with- Gtk.Entryto provide the completion functionality. It implements the- Gtk.CellLayoutinterface, to allow the user to add extra cells to the- Gtk.TreeViewwith completion matches.- “Completion functionality” means that when the user modifies the text in the entry, - Gtk.EntryCompletionchecks 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- Gtk.EntryCompletion.set_text_column()), but this can be overridden with a custom match function (see- 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 - Gtk.EntryCompletion- ::match-selectedsignal and updating the entry in the signal handler. Note that you should return- Truefrom the signal handler to suppress the default behaviour.- To add completion functionality to an entry, use - Gtk.Entry.set_completion().- In addition to regular completion matches, which will be inserted into the entry when they are selected, - Gtk.EntryCompletionalso allows to display “actions” in the popup window. Their appearance is similar to menuitems, to differentiate them clearly from completion strings. When an action is selected, the- Gtk.EntryCompletion- ::action-activatedsignal is emitted.- Gtk.EntryCompletionuses a- Gtk.TreeModelFiltermodel to represent the subset of the entire model that is currently matching. While the- Gtk.EntryCompletionsignals- Gtk.EntryCompletion- ::match-selectedand- Gtk.EntryCompletion- ::cursor-on-matchtake the original model and an iter pointing to that model as arguments, other callbacks and signals (such as- Gtk.CellLayoutDataFuncsor- Gtk.CellArea- ::apply-attributes) will generally take the filter model as argument. As long as you are only calling- Gtk.TreeModel.get(), this will make no difference to you. If for some reason, you need the original model, use- Gtk.TreeModelFilter.get_model(). Don’t forget to use- Gtk.TreeModelFilter.convert_iter_to_child_iter() to obtain a matching iter.- 
classmethod new()[source]¶
- Returns: - A newly created - Gtk.EntryCompletionobject- Return type: - Gtk.EntryCompletion- Creates a new - Gtk.EntryCompletionobject.- New in version 2.4. 
 - 
classmethod new_with_area(area)[source]¶
- Parameters: - area ( - Gtk.CellArea) – the- Gtk.CellAreaused to layout cells- Returns: - A newly created - Gtk.EntryCompletionobject- Return type: - Gtk.EntryCompletion- Creates a new - Gtk.EntryCompletionobject using the specified area to layout cells in the underlying- Gtk.TreeViewColumnfor the drop-down menu.- New in version 3.0. 
 - 
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. - New in version 2.4. 
 - 
compute_prefix(key)[source]¶
- Parameters: - key ( - str) – The text to complete for- Returns: - The common prefix all rows starting with key or - Noneif no row matches key.- Return type: - stror- None- Computes the common prefix that is shared by all rows in self that start with key. If no row matches key, - Nonewill be returned. Note that a text column must have been set for this function to work, see- Gtk.EntryCompletion.set_text_column() for details.- New in version 3.4. 
 - 
delete_action(index_)[source]¶
- Parameters: - index ( - int) – the index of the item to delete- Deletes the action at index_ from self’s action list. - Note that index_ is a relative position and the position of an action may have changed since it was inserted. - New in version 2.4. 
 - 
get_completion_prefix()[source]¶
- Returns: - the prefix for the current completion - Return type: - str- Get the original text entered by the user that triggered the completion or - Noneif there’s no completion ongoing.- New in version 2.12. 
 - 
get_entry()[source]¶
- Returns: - The entry self has been attached to - Return type: - Gtk.Widget- Gets the entry self has been attached to. - New in version 2.4. 
 - 
get_inline_completion()[source]¶
- Returns: - Trueif inline completion is turned on- Return type: - bool- Returns whether the common prefix of the possible completions should be automatically inserted in the entry. - New in version 2.6. 
 - 
get_inline_selection()[source]¶
- Returns: - Trueif inline-selection mode is on- Return type: - bool- Returns - Trueif inline-selection mode is turned on.- New in version 2.12. 
 - 
get_minimum_key_length()[source]¶
- Returns: - The currently used minimum key length - Return type: - int- Returns the minimum key length as set for self. - New in version 2.4. 
 - 
get_model()[source]¶
- Returns: - A - Gtk.TreeModel, or- Noneif none is currently being used- Return type: - Gtk.TreeModelor- None- Returns the model the - Gtk.EntryCompletionis using as data source. Returns- Noneif the model is unset.- New in version 2.4. 
 - 
get_popup_completion()[source]¶
- Returns: - Trueif popup completion is turned on- Return type: - bool- Returns whether the completions should be presented in a popup window. - New in version 2.6. 
 - 
get_popup_set_width()[source]¶
- Returns: - Trueif the popup window will be resized to the width of the entry- Return type: - bool- Returns whether the completion popup window will be resized to the width of the entry. - New in version 2.8. 
 - 
get_popup_single_match()[source]¶
- Returns: - Trueif the popup window will appear regardless of the number of matches- Return type: - bool- Returns whether the completion popup window will appear even if there is only a single match. - New in version 2.8. 
 - 
get_text_column()[source]¶
- Returns: - the column containing the strings - Return type: - int- Returns the column in the model of self to get strings from. - New in version 2.6. 
 - 
insert_action_markup(index_, markup)[source]¶
- Parameters: - Inserts an action in self’s action item list at position index_ with markup markup. - New in version 2.4. 
 - 
insert_action_text(index_, text)[source]¶
- Parameters: - Inserts an action in self’s action item list at position index_ with text text. If you want the action item to have markup, use - Gtk.EntryCompletion.insert_action_markup().- Note that index_ is a relative position in the list of actions and the position of an action can change when deleting a different action. - New in version 2.4. 
 - 
set_inline_completion(inline_completion)[source]¶
- Parameters: - inline_completion ( - bool) –- Trueto do inline completion- Sets whether the common prefix of the possible completions should be automatically inserted in the entry. - New in version 2.6. 
 - 
set_inline_selection(inline_selection)[source]¶
- Parameters: - inline_selection ( - bool) –- Trueto do inline selection- Sets whether it is possible to cycle through the possible completions inside the entry. - New in version 2.12. 
 - 
set_match_func(func, *func_data)[source]¶
- Parameters: - func (Gtk.EntryCompletionMatchFunc) – theGtk.EntryCompletionMatchFuncto use
- func_data (objectorNone) – user data for func
 - 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. - New in version 2.4. 
- func (
 - 
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). - New in version 2.4. 
 - 
set_model(model)[source]¶
- Parameters: - model ( - Gtk.TreeModelor- None) – the- Gtk.TreeModel- Sets the model for a - Gtk.EntryCompletion. 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.- New in version 2.4. 
 - 
set_popup_completion(popup_completion)[source]¶
- Parameters: - popup_completion ( - bool) –- Trueto do popup completion- Sets whether the completions should be presented in a popup window. - New in version 2.6. 
 - 
set_popup_set_width(popup_set_width)[source]¶
- Parameters: - popup_set_width ( - bool) –- Trueto make the width of the popup the same as the entry- Sets whether the completion popup window will be resized to be the same width as the entry. - New in version 2.8. 
 - 
set_popup_single_match(popup_single_match)[source]¶
- Parameters: - popup_single_match ( - bool) –- Trueif the popup should appear even for a single match- 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 using- inline completion.- New in version 2.8. 
 - 
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 - Gtk.CellRendererTextfor 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- Gtk.EntryCompletion- :text-columnproperty directly.- New in version 2.4. 
 - 
do_cursor_on_match(model, iter) virtual¶
- Parameters: - model (Gtk.TreeModel) –
- iter (Gtk.TreeIter) –
 - Return type: 
- model (
 - 
do_match_selected(model, iter) virtual¶
- Parameters: - model (Gtk.TreeModel) –
- iter (Gtk.TreeIter) –
 - Return type: 
- model (
 - 
do_no_matches() virtual¶
 
- 
classmethod 
Signal Details¶
- 
Gtk.EntryCompletion.signals.action_activated(entry_completion, index)¶
- Signal Name: - action-activated- Flags: - Parameters: - entry_completion (Gtk.EntryCompletion) – The object which received the signal
- index (int) – the index of the activated action
 - Gets emitted when an action is activated. - New in version 2.4. 
- entry_completion (
- 
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 signal
- model (Gtk.TreeModel) – theGtk.TreeModelcontaining the matches
- iter (Gtk.TreeIter) – aGtk.TreeIterpositioned at the selected match
 - Returns: - Trueif the signal has been handled- Return type: - Gets 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 - Gtk.EntryCompletion.set_model().- New in version 2.12. 
- entry_completion (
- 
Gtk.EntryCompletion.signals.insert_prefix(entry_completion, prefix)¶
- Signal Name: - insert-prefix- Flags: - Parameters: - entry_completion (Gtk.EntryCompletion) – The object which received the signal
- prefix (str) – the common prefix of all possible completions
 - Returns: - Trueif the signal has been handled- Return type: - Gets 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 - Gtk.FileChooserinserts only the part of the prefix up to the next ‘/’.- New in version 2.6. 
- entry_completion (
- 
Gtk.EntryCompletion.signals.match_selected(entry_completion, model, iter)¶
- Signal Name: - match-selected- Flags: - Parameters: - entry_completion (Gtk.EntryCompletion) – The object which received the signal
- model (Gtk.TreeModel) – theGtk.TreeModelcontaining the matches
- iter (Gtk.TreeIter) – aGtk.TreeIterpositioned at the selected match
 - Returns: - Trueif the signal has been handled- Return type: - Gets 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 - Gtk.EntryCompletion.set_model().- New in version 2.4. 
- entry_completion (
- 
Gtk.EntryCompletion.signals.no_matches(entry_completion)¶
- Signal Name: - no-matches- Flags: - RUN_LAST- Parameters: - entry_completion ( - Gtk.EntryCompletion) – The object which received the signal- Gets emitted when the filter model has zero number of rows in completion_complete method. (In other words when - Gtk.EntryCompletionis out of suggestions)- New in version 3.14. 
Property Details¶
- 
Gtk.EntryCompletion.props.cell_area¶
- Name: - cell-area- Type: - Gtk.CellArea- Default Value: - None- Flags: - READABLE,- WRITABLE,- CONSTRUCT_ONLY- The - Gtk.CellAreaused to layout cell renderers in the treeview column.- If no area is specified when creating the entry completion with - Gtk.EntryCompletion.new_with_area() a horizontally oriented- Gtk.CellAreaBoxwill be used.- New in version 3.0. 
- 
Gtk.EntryCompletion.props.inline_completion¶
- Name: - inline-completion- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- 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. - New in version 2.6. 
- 
Gtk.EntryCompletion.props.inline_selection¶
- Name: - inline-selection- Type: - bool- Default Value: - False- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- Determines whether the possible completions on the popup will appear in the entry as you navigate through them. - New in version 2.12. 
- 
Gtk.EntryCompletion.props.minimum_key_length¶
- Name: - minimum-key-length- Type: - int- Default Value: - 1- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- Minimum length of the search key in order to look up matches 
- 
Gtk.EntryCompletion.props.model¶
- Name: - model- Type: - Gtk.TreeModel- Default Value: - None- Flags: - READABLE,- WRITABLE- The model to find matches in 
- 
Gtk.EntryCompletion.props.popup_completion¶
- Name: - popup-completion- Type: - bool- Default Value: - True- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- Determines whether the possible completions should be shown in a popup window. - New in version 2.6. 
- 
Gtk.EntryCompletion.props.popup_set_width¶
- Name: - popup-set-width- Type: - bool- Default Value: - True- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- Determines whether the completions popup window will be resized to the width of the entry. - New in version 2.8. 
- 
Gtk.EntryCompletion.props.popup_single_match¶
- Name: - popup-single-match- Type: - bool- Default Value: - True- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- Determines whether the completions popup window will shown for a single possible completion. You probably want to set this to - Falseif you are using- inline completion.- New in version 2.8.