Gtk.TreeSelection¶
| Subclasses: | None | 
|---|
Methods¶
| Inherited: | GObject.Object (37) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| count_selected_rows() | |
| get_mode() | |
| get_selected() | |
| get_selected_rows() | |
| get_tree_view() | |
| iter_is_selected(iter) | |
| path_is_selected(path) | |
| select_all() | |
| select_iter(iter) | |
| select_path(path) | |
| select_range(start_path, end_path) | |
| selected_foreach(func, *data) | |
| set_mode(type) | |
| set_select_function(func, *data) | |
| unselect_all() | |
| unselect_iter(iter) | |
| unselect_path(path) | |
| unselect_range(start_path, end_path) | 
Properties¶
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| mode | Gtk.SelectionMode | r/w/en | Selection mode | 
Signals¶
| Inherited: | GObject.Object (1) | 
|---|
| Name | Short Description | 
|---|---|
| changed | Emitted whenever the selection has (possibly) changed. | 
Class Details¶
- 
class Gtk.TreeSelection(**kwargs)¶
- Bases: - GObject.Object- Abstract: - No - Structure: - Gtk.TreeSelectionClass- The - Gtk.TreeSelectionobject is a helper object to manage the selection for a- Gtk.TreeViewwidget. The- Gtk.TreeSelectionobject is automatically created when a new- Gtk.TreeViewwidget is created, and cannot exist independently of this widget. The primary reason the- Gtk.TreeSelectionobjects exists is for cleanliness of code and API. That is, there is no conceptual reason all these functions could not be methods on the- Gtk.TreeViewwidget instead of a separate function.- The - Gtk.TreeSelectionobject is gotten from a- Gtk.TreeViewby calling- Gtk.TreeView.get_selection(). It can be manipulated to check the selection status of the tree, as well as select and deselect individual rows. Selection is done completely view side. As a result, multiple views of the same model can have completely different selections. Additionally, you cannot change the selection of a row on the model that is not currently displayed by the view without expanding its parents first.- One of the important things to remember when monitoring the selection of a view is that the - Gtk.TreeSelection- ::changedsignal is mostly a hint. That is, it may only emit one signal when a range of rows is selected. Additionally, it may on occasion emit a- Gtk.TreeSelection- ::changedsignal when nothing has happened (mostly as a result of programmers calling select_row on an already selected row).- 
count_selected_rows()[source]¶
- Returns: - The number of rows selected. - Return type: - int- Returns the number of rows that have been selected in tree. - New in version 2.2. 
 - 
get_mode()[source]¶
- Returns: - the current selection mode - Return type: - Gtk.SelectionMode- Gets the selection mode for self. See - Gtk.TreeSelection.set_mode().
 - 
get_selected()[source]¶
- Returns: - model: - the - Gtk.TreeModel- iter: - The - Gtk.TreeIteror- None- Return type: - (model: - Gtk.TreeModel, iter:- Gtk.TreeIteror- None)- Sets iter to the currently selected node if self is set to - Gtk.SelectionMode.SINGLEor- Gtk.SelectionMode.BROWSE. iter may be- Noneif you just want to test if self has any selected nodes. model is filled with the current model as a convenience. This function will not work if you use self is- Gtk.SelectionMode.MULTIPLE.
 - 
get_selected_rows()[source]¶
- Returns: - A list containing a - Gtk.TreePathfor each selected row and a- Gtk.TreeModelor- None.- Return type: - ( - Gtk.TreeModel, [- Gtk.TreePath])- Creates a list of path of all selected rows. Additionally, if you are planning on modifying the model after calling this function, you may want to convert the returned list into a list of - Gtk.TreeRowReferences. To do this, you can use- Gtk.TreeRowReference.new().- To free the return value, use: - g_list_free_full (list, (GDestroyNotify) gtk_tree_path_free);- New in version 2.2. 
 - 
get_tree_view()[source]¶
- Returns: - A - Gtk.TreeView- Return type: - Gtk.TreeView- Returns the tree view associated with self. 
 - 
iter_is_selected(iter)[source]¶
- Parameters: - iter ( - Gtk.TreeIter) – A valid- Gtk.TreeIter- Returns: - True, if iter is selected- Return type: - bool- Returns - Trueif the row at iter is currently selected.
 - 
path_is_selected(path)[source]¶
- Parameters: - path ( - Gtk.TreePath) – A- Gtk.TreePathto check selection on.- Returns: - Trueif path is selected.- Return type: - bool- Returns - Trueif the row pointed to by path is currently selected. If path does not point to a valid location,- Falseis returned
 - 
select_all()[source]¶
- Selects all the nodes. self must be set to - Gtk.SelectionMode.MULTIPLEmode.
 - 
select_iter(iter)[source]¶
- Parameters: - iter ( - Gtk.TreeIter) – The- Gtk.TreeIterto be selected.- Selects the specified iterator. 
 - 
select_path(path)[source]¶
- Parameters: - path ( - Gtk.TreePath) – The- Gtk.TreePathto be selected.- Select the row at path. 
 - 
select_range(start_path, end_path)[source]¶
- Parameters: - start_path (Gtk.TreePath) – The initial node of the range.
- end_path (Gtk.TreePath) – The final node of the range.
 - Selects a range of nodes, determined by start_path and end_path inclusive. self must be set to - Gtk.SelectionMode.MULTIPLEmode.
- start_path (
 - 
selected_foreach(func, *data)[source]¶
- Parameters: - func (Gtk.TreeSelectionForeachFunc) – The function to call for each selected node.
- data (objectorNone) – user data to pass to the function.
 - Calls a function for each selected node. Note that you cannot modify the tree or selection from within this function. As a result, - Gtk.TreeSelection.get_selected_rows() might be more useful.
- func (
 - 
set_mode(type)[source]¶
- Parameters: - type ( - Gtk.SelectionMode) – The selection mode- Sets the selection mode of the self. If the previous type was - Gtk.SelectionMode.MULTIPLE, then the anchor is kept selected, if it was previously selected.
 - 
set_select_function(func, *data)[source]¶
- Parameters: - Sets the selection function. - If set, this function is called before any node is selected or unselected, giving some control over which nodes are selected. The select function should return - Trueif the state of the node may be toggled, and- Falseif the state of the node should be left unchanged.
 - 
unselect_iter(iter)[source]¶
- Parameters: - iter ( - Gtk.TreeIter) – The- Gtk.TreeIterto be unselected.- Unselects the specified iterator. 
 - 
unselect_path(path)[source]¶
- Parameters: - path ( - Gtk.TreePath) – The- Gtk.TreePathto be unselected.- Unselects the row at path. 
 - 
unselect_range(start_path, end_path)[source]¶
- Parameters: - start_path (Gtk.TreePath) – The initial node of the range.
- end_path (Gtk.TreePath) – The initial node of the range.
 - Unselects a range of nodes, determined by start_path and end_path inclusive. - New in version 2.2. 
- start_path (
 - 
do_changed() virtual¶
 
- 
Signal Details¶
- 
Gtk.TreeSelection.signals.changed(tree_selection)¶
- Signal Name: - changed- Flags: - RUN_FIRST- Parameters: - tree_selection ( - Gtk.TreeSelection) – The object which received the signal- Emitted whenever the selection has (possibly) changed. Please note that this signal is mostly a hint. It may only be emitted once when a range of rows are selected, and it may occasionally be emitted when nothing has happened. 
Property Details¶
- 
Gtk.TreeSelection.props.mode¶
- Name: - mode- Type: - Gtk.SelectionMode- Default Value: - Gtk.SelectionMode.SINGLE- Flags: - READABLE,- WRITABLE,- EXPLICIT_NOTIFY- Selection mode. See - Gtk.TreeSelection.set_mode() for more information on this property.- New in version 3.2.