Gtk.TreeSelection¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted whenever the selection has (possibly) changed. |
Fields¶
- Inherited:
Class Details¶
- class Gtk.TreeSelection(**kwargs)¶
- Bases:
- Abstract:
No
The selection object for
Gtk.TreeView
The
GtkTreeSelection
object is a helper object to manage the selection for aGtkTreeView
widget. TheGtkTreeSelection
object is automatically created when a newGtkTreeView
widget is created, and cannot exist independently of this widget. The primary reason theGtkTreeSelection
objects exists is for cleanliness of code and API. That is, there is no conceptual reason all these functions could not be methods on theGtkTreeView
widget instead of a separate function.The
GtkTreeSelection
object is gotten from aGtkTreeView
by callingGtk.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
GtkTreeSelection
::changed
signal 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 aGtkTreeSelection
::changed
signal when nothing has happened (mostly as a result of programmers calling select_row on an already selected row).Deprecated since version 4.10: Use [iface`Gtk`.SelectionModel] instead
- count_selected_rows()[source]¶
- Returns:
The number of rows selected.
- Return type:
Returns the number of rows that have been selected in tree.
Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- get_mode()[source]¶
- Returns:
the current selection mode
- Return type:
Gets the selection mode for self. See
Gtk.TreeSelection.set_mode
().Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- get_selected()[source]¶
- Returns:
- model:
the
Gtk.TreeModel
- iter:
The
Gtk.TreeIter
orNone
- Return type:
(model:
Gtk.TreeModel
, iter:Gtk.TreeIter
orNone
)
Sets iter to the currently selected node if self is set to
Gtk.SelectionMode.SINGLE
orGtk.SelectionMode.BROWSE
. iter may beNone
if 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 isGtk.SelectionMode.MULTIPLE
.Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- get_selected_rows()[source]¶
- Returns:
A list containing a
Gtk.TreePath
for each selected row and aGtk.TreeModel
orNone
.- Return type:
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 ``GtkTreeRowReference``s. 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);
Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- get_tree_view()[source]¶
- Returns:
A
GtkTreeView
- Return type:
Returns the tree view associated with self.
Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- iter_is_selected(iter)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – A validGtkTreeIter
- Returns:
True
, if iter is selected- Return type:
Returns
True
if the row at iter is currently selected.Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- path_is_selected(path)[source]¶
- Parameters:
path (
Gtk.TreePath
) – AGtkTreePath
to check selection on.- Returns:
True
if path is selected.- Return type:
Returns
True
if the row pointed to by path is currently selected. If path does not point to a valid location,False
is returnedDeprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- select_all()[source]¶
Selects all the nodes. self must be set to
Gtk.SelectionMode.MULTIPLE
mode.Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- select_iter(iter)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – TheGtkTreeIter
to be selected.
Selects the specified iterator.
Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- select_path(path)[source]¶
- Parameters:
path (
Gtk.TreePath
) – TheGtkTreePath
to be selected.
Select the row at path.
Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- 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.MULTIPLE
mode.Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- selected_foreach(func, *data)[source]¶
- Parameters:
func (
Gtk.TreeSelectionForeachFunc
) – The function to call for each selected node.
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.Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- 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.Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- 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
True
if the state of the node may be toggled, andFalse
if the state of the node should be left unchanged.Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- unselect_all()[source]¶
Unselects all the nodes.
Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- unselect_iter(iter)[source]¶
- Parameters:
iter (
Gtk.TreeIter
) – TheGtkTreeIter
to be unselected.
Unselects the specified iterator.
Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- unselect_path(path)[source]¶
- Parameters:
path (
Gtk.TreePath
) – TheGtkTreePath
to be unselected.
Unselects the row at path.
Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
- 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.
Deprecated since version 4.10: Use
Gtk.ListView
orGtk.ColumnView
Signal Details¶
- Gtk.TreeSelection.signals.changed(tree_selection)¶
- Signal Name:
changed
- Flags:
- 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:
- Default Value:
- Flags:
Selection mode. See
Gtk.TreeSelection.set_mode
() for more information on this property.