Gtk.EntryCompletion¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The |
||
r/w/en |
Whether the common prefix should be inserted automatically |
||
r/w/en |
Your description here |
||
r/w/en |
Minimum length of the search key in order to look up matches |
||
r/w |
The model to find matches in |
||
r/w/en |
Whether the completions should be shown in a popup window |
||
r/w/en |
If |
||
r/w/en |
If |
||
r/w |
The column of the model containing the strings. |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Gets emitted when an action is activated. |
|
Gets emitted when a match from the cursor is on a match of the list. |
|
Gets emitted when the inline autocompletion is triggered. |
|
Gets emitted when a match from the list is selected. |
|
Gets emitted when the filter model has zero number of rows in completion_complete method. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent_instance |
r |
Class Details¶
- class Gtk.EntryCompletion(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Gtk.EntryCompletion
is an auxiliary object to be used in conjunction withGtk.Entry
to provide the completion functionality. It implements theGtk.CellLayout
interface, to allow the user to add extra cells to theGtk.TreeView
with completion matches.“Completion functionality” means that when the user modifies the text in the entry,
Gtk.EntryCompletion
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 (seeGtk.EntryCompletion.set_text_column
()), but this can be overridden with a custom match function (seeGtk.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-selected
signal and updating the entry in the signal handler. Note that you should returnTrue
from 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.EntryCompletion
also 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, theGtk.EntryCompletion
::action-activated
signal is emitted.Gtk.EntryCompletion
uses aGtk.TreeModelFilter
model to represent the subset of the entire model that is currently matching. While theGtk.EntryCompletion
signalsGtk.EntryCompletion
::match-selected
andGtk.EntryCompletion
::cursor-on-match
take the original model and an iter pointing to that model as arguments, other callbacks and signals (such asGtk.CellLayoutDataFuncs
orGtk.CellArea
::apply-attributes
) will generally take the filter model as argument. As long as you are only callingGtk.TreeModel.get
(), this will make no difference to you. If for some reason, you need the original model, useGtk.TreeModelFilter.get_model
(). Don’t forget to useGtk.TreeModelFilter.convert_iter_to_child_iter
() to obtain a matching iter.- classmethod new()[source]¶
- Returns:
A newly created
Gtk.EntryCompletion
object- Return type:
Creates a new
Gtk.EntryCompletion
object.New in version 2.4.
- classmethod new_with_area(area)[source]¶
- Parameters:
area (
Gtk.CellArea
) – theGtk.CellArea
used to layout cells- Returns:
A newly created
Gtk.EntryCompletion
object- Return type:
Creates a new
Gtk.EntryCompletion
object using the specified area to layout cells in the underlyingGtk.TreeViewColumn
for 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
None
if no row matches 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, seeGtk.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:
Get the original text entered by the user that triggered the completion or
None
if there’s no completion ongoing.New in version 2.12.
- get_entry()[source]¶
- Returns:
The entry self has been attached to
- Return type:
Gets the entry self has been attached to.
New in version 2.4.
- get_inline_completion()[source]¶
-
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
True
if 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:
Returns the minimum key length as set for self.
New in version 2.4.
- get_model()[source]¶
- Returns:
A
Gtk.TreeModel
, orNone
if none is currently being used- Return type:
Returns the model the
Gtk.EntryCompletion
is using as data source. ReturnsNone
if the model is unset.New in version 2.4.
- get_popup_completion()[source]¶
-
Returns whether the completions should be presented in a popup window.
New in version 2.6.
- get_popup_set_width()[source]¶
-
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 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:
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]¶
-
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]¶
-
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]¶
-
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.EntryCompletionMatchFunc
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.
New in version 2.4.
- 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.TreeModel
orNone
) – theGtk.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 isNone
, then it will unset the model.New in version 2.4.
- set_popup_completion(popup_completion)[source]¶
-
Sets whether the completions should be presented in a popup window.
New in version 2.6.
- 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.
New in version 2.8.
- 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 usinginline 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.CellRendererText
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 theGtk.EntryCompletion
:text-column
property directly.New in version 2.4.
- do_cursor_on_match(model, iter) virtual¶
- Parameters:
model (
Gtk.TreeModel
) –iter (
Gtk.TreeIter
) –
- Return type:
- do_match_selected(model, iter) virtual¶
- Parameters:
model (
Gtk.TreeModel
) –iter (
Gtk.TreeIter
) –
- Return type:
- do_no_matches() virtual¶
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 signalindex (
int
) – the index of the activated action
Gets emitted when an action is activated.
New in version 2.4.
- 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
) – theGtk.TreeModel
containing the matchesiter (
Gtk.TreeIter
) – aGtk.TreeIter
positioned at the selected match
- Returns:
True
if 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.
- 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:
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.FileChooser
inserts only the part of the prefix up to the next ‘/’.New in version 2.6.
- 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
) – theGtk.TreeModel
containing the matchesiter (
Gtk.TreeIter
) – aGtk.TreeIter
positioned at the selected match
- Returns:
True
if 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.
- Gtk.EntryCompletion.signals.no_matches(entry_completion)¶
- Signal Name:
no-matches
- Flags:
- 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.EntryCompletion
is out of suggestions)New in version 3.14.
Property Details¶
- Gtk.EntryCompletion.props.cell_area¶
- Name:
cell-area
- Type:
- Default Value:
- Flags:
The
Gtk.CellArea
used 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 orientedGtk.CellAreaBox
will be used.New in version 3.0.
- 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.
New in version 2.6.
- 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.
New in version 2.12.
- Gtk.EntryCompletion.props.minimum_key_length¶
- Name:
minimum-key-length
- Type:
- Default Value:
1
- Flags:
Minimum length of the search key in order to look up matches
- Gtk.EntryCompletion.props.model¶
- Name:
model
- Type:
- Default Value:
- Flags:
The model to find matches in
- Gtk.EntryCompletion.props.popup_completion¶
- Name:
popup-completion
- Type:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
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:
- Default Value:
- Flags:
Determines whether the completions popup window will shown for a single possible completion. You probably want to set this to
False
if you are usinginline completion
.New in version 2.8.