Gtk.TreeView¶
Example¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Container (35), Gtk.Widget (278), GObject.Object (37), Gtk.Buildable (10), Gtk.Scrollable (9)
- Structs:
Gtk.ContainerClass (5), Gtk.WidgetClass (12), GObject.ObjectClass (5)
Virtual Methods¶
- Inherited:
Gtk.Container (10), Gtk.Widget (82), GObject.Object (7), Gtk.Buildable (10), Gtk.Scrollable (1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
Activate row on a single click |
||
r/w/en |
Whether grid lines should be drawn in the tree view |
||
r/w/en |
View allows user to search through columns interactively |
||
r/w/en |
Whether tree lines should be drawn in the tree view |
||
r/w |
Set the column for the expander column |
||
r/w/en |
Speeds up |
||
r/w/en |
Column headers respond to click events |
||
r/w/en |
Show the column header buttons |
||
r/w/en |
Whether rows should be expanded/collapsed when the pointer moves over them |
||
r/w/en |
Whether the selection should follow the pointer |
||
r/w/en |
Extra indentation for each level |
||
r/w |
The model for the tree view |
||
r/w/en |
View is reorderable |
||
r/w/en |
Whether to enable selection of multiple items by dragging the mouse pointer |
||
d/r/w/en |
Set a hint to the theme engine to draw rows in alternating colors |
||
r/w/en |
Model column to search through during interactive search |
||
r/w/en |
View has expanders |
||
r/w/en |
The column in the model containing the tooltip texts for the rows |
Style Properties¶
- Inherited:
Name |
Type |
Default |
Flags |
Short Description |
---|---|---|---|---|
|
r |
Allow drawing of alternating color rows |
||
|
r |
Color to use for even rows |
||
|
|
r |
Size of the expander arrow |
|
|
|
r |
Dash pattern used to draw the tree view grid lines |
|
|
|
r |
Width, in pixels, of the tree view grid lines |
|
|
|
r |
Horizontal space between cells. Must be an even number |
|
|
r |
Make the expanders indented |
||
|
r |
Color to use for odd rows |
||
|
|
r |
Dash pattern used to draw the tree view lines |
|
|
|
r |
Width, in pixels, of the tree view lines |
|
|
|
r |
Vertical space between cells. Must be an even number |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
The number of columns of the treeview has changed. |
|
The position of the cursor (focused cell) has changed. |
|
The |
|
The “row-activated” signal is emitted when the method |
|
The given row has been collapsed (child nodes are hidden). |
|
The given row has been expanded (child nodes are shown). |
|
The given row is about to be collapsed (hide its children nodes). |
|
The given row is about to be expanded (show its children nodes). |
|
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class Gtk.TreeView(*args, **kwargs)¶
- Bases:
- Abstract:
No
- Structure:
Widget that displays any object that implements the
Gtk.TreeModel
interface.Please refer to the tree widget conceptual overview for an overview of all the objects and data types related to the tree widget and how they work together.
Several different coordinate systems are exposed in the
Gtk.TreeView
API. These are:Coordinate systems in
Gtk.TreeView
API:Widget coordinates: Coordinates relative to the widget (usually
widget->window
).Bin window coordinates: Coordinates relative to the window that
Gtk.TreeView
renders to.Tree coordinates: Coordinates relative to the entire scrollable area of
Gtk.TreeView
. These coordinates start at (0, 0) for row 0 of the tree.
Several functions are available for converting between the different coordinate systems. The most common translations are between widget and bin window coordinates and between bin window and tree coordinates. For the former you can use
Gtk.TreeView.convert_widget_to_bin_window_coords
() (and vice versa), for the latterGtk.TreeView.convert_bin_window_to_tree_coords
() (and vice versa).The
Gtk.TreeView
implementation of theGtk.Buildable
interface acceptsGtk.TreeViewColumn
objects as<child>
elements and exposes the internalGtk.TreeSelection
in UI definitions.An example of a UI definition fragment with
Gtk.TreeView
:<object class="GtkTreeView" id="treeview"> <property name="model">liststore1</property> <child> <object class="GtkTreeViewColumn" id="test-column"> <property name="title">Test</property> <child> <object class="GtkCellRendererText" id="test-renderer"/> <attributes> <attribute name="text">1</attribute> </attributes> </child> </object> </child> <child internal-child="selection"> <object class="GtkTreeSelection" id="selection"> <signal name="changed" handler="on_treeview_selection_changed"/> </object> </child> </object>
- CSS nodes
treeview.view ├── header │ ├── <column header> ┊ ┊ │ ╰── <column header> │ ╰── [rubberband]
Gtk.TreeView
has a main CSS node with name treeview and style class .view. It has a subnode with name header, which is the parent for all the column header widgets’ CSS nodes. For rubberband selection, a subnode with name rubberband is used.- classmethod new()[source]¶
- Returns:
A newly created
Gtk.TreeView
widget.- Return type:
Creates a new
Gtk.TreeView
widget.
- classmethod new_with_model(model)[source]¶
- Parameters:
model (
Gtk.TreeModel
) – the model.- Returns:
A newly created
Gtk.TreeView
widget.- Return type:
Creates a new
Gtk.TreeView
widget with the model initialized to model.
- append_column(column)[source]¶
- Parameters:
column (
Gtk.TreeViewColumn
) – TheGtk.TreeViewColumn
to add.- Returns:
The number of columns in self after appending.
- Return type:
Appends column to the list of columns. If self has “fixed_height” mode enabled, then column must have its “sizing” property set to be
Gtk.TreeViewColumnSizing.FIXED
.
- collapse_row(path)[source]¶
- Parameters:
path (
Gtk.TreePath
) – path to a row in the self- Returns:
True
if the row was collapsed.- Return type:
Collapses a row (hides its child rows, if they exist).
- columns_autosize()[source]¶
Resizes all columns to their optimal width. Only works after the treeview has been realized.
- convert_bin_window_to_tree_coords(bx, by)[source]¶
- Parameters:
- Returns:
- tx:
return location for tree X coordinate
- ty:
return location for tree Y coordinate
- Return type:
Converts bin_window coordinates to coordinates for the tree (the full scrollable area of the tree).
New in version 2.12.
- convert_bin_window_to_widget_coords(bx, by)[source]¶
- Parameters:
- Returns:
- wx:
return location for widget X coordinate
- wy:
return location for widget Y coordinate
- Return type:
Converts bin_window coordinates (see
Gtk.TreeView.get_bin_window
()) to widget relative coordinates.New in version 2.12.
- convert_tree_to_bin_window_coords(tx, ty)[source]¶
- Parameters:
- Returns:
- bx:
return location for X coordinate relative to bin_window
- by:
return location for Y coordinate relative to bin_window
- Return type:
Converts tree coordinates (coordinates in full scrollable area of the tree) to bin_window coordinates.
New in version 2.12.
- convert_tree_to_widget_coords(tx, ty)[source]¶
- Parameters:
- Returns:
- wx:
return location for widget X coordinate
- wy:
return location for widget Y coordinate
- Return type:
Converts tree coordinates (coordinates in full scrollable area of the tree) to widget coordinates.
New in version 2.12.
- convert_widget_to_bin_window_coords(wx, wy)[source]¶
- Parameters:
- Returns:
- bx:
return location for bin_window X coordinate
- by:
return location for bin_window Y coordinate
- Return type:
Converts widget coordinates to coordinates for the bin_window (see
Gtk.TreeView.get_bin_window
()).New in version 2.12.
- convert_widget_to_tree_coords(wx, wy)[source]¶
- Parameters:
- Returns:
- tx:
return location for tree X coordinate
- ty:
return location for tree Y coordinate
- Return type:
Converts widget coordinates to coordinates for the tree (the full scrollable area of the tree).
New in version 2.12.
- create_row_drag_icon(path)[source]¶
- Parameters:
path (
Gtk.TreePath
) – aGtk.TreePath
in self- Returns:
a newly-allocated surface of the drag icon.
- Return type:
Creates a
cairo.Surface
representation of the row at path. This image is used for a drag icon.
- enable_model_drag_dest(targets, actions)[source]¶
- Parameters:
targets ([
Gtk.TargetEntry
]) – the table of targets that the drag will supportactions (
Gdk.DragAction
) – the bitmask of possible actions for a drag from this widget
Turns self into a drop destination for automatic DND. Calling this method sets
Gtk.TreeView
:reorderable
toFalse
.
- enable_model_drag_source(start_button_mask, targets, actions)[source]¶
- Parameters:
start_button_mask (
Gdk.ModifierType
) – Mask of allowed buttons to start dragtargets ([
Gtk.TargetEntry
]) – the table of targets that the drag will supportactions (
Gdk.DragAction
) – the bitmask of possible actions for a drag from this widget
Turns self into a drag source for automatic DND. Calling this method sets
Gtk.TreeView
:reorderable
toFalse
.
- expand_row(path, open_all)[source]¶
- Parameters:
path (
Gtk.TreePath
) – path to a rowopen_all (
bool
) – whether to recursively expand, or just expand immediate children
- Returns:
True
if the row existed and had children- Return type:
Opens the row so its children are visible.
- expand_to_path(path)[source]¶
- Parameters:
path (
Gtk.TreePath
) – path to a row.
Expands the row at path. This will also expand all parent rows of path as necessary.
New in version 2.2.
- get_activate_on_single_click()[source]¶
-
Gets the setting set by
Gtk.TreeView.set_activate_on_single_click
().New in version 3.8.
- get_background_area(path, column)[source]¶
- Parameters:
path (
Gtk.TreePath
orNone
) – aGtk.TreePath
for the row, orNone
to get only horizontal coordinatescolumn (
Gtk.TreeViewColumn
orNone
) – aGtk.TreeViewColumn
for the column, orNone
to get only vertical coordiantes
- Returns:
rectangle to fill with cell background rect
- Return type:
rect:
Gdk.Rectangle
Fills the bounding rectangle in bin_window coordinates for the cell at the row specified by path and the column specified by column. If path is
None
, or points to a node not found in the tree, the y and height fields of the rectangle will be filled with 0. If column isNone
, the x and width fields will be filled with 0. The returned rectangle is equivalent to the background_area passed toGtk.CellRenderer.render
(). These background areas tile to cover the entire bin window. Contrast with the cell_area, returned byGtk.TreeView.get_cell_area
(), which returns only the cell itself, excluding surrounding borders and the tree expander area.
- get_bin_window()[source]¶
- Returns:
A
Gdk.Window
, orNone
when self hasn’t been realized yet.- Return type:
Gdk.Window
orNone
Returns the window that self renders to. This is used primarily to compare to
event->window
to confirm that the event on self is on the right window.
- get_cell_area(path, column)[source]¶
- Parameters:
path (
Gtk.TreePath
orNone
) – aGtk.TreePath
for the row, orNone
to get only horizontal coordinatescolumn (
Gtk.TreeViewColumn
orNone
) – aGtk.TreeViewColumn
for the column, orNone
to get only vertical coordinates
- Returns:
rectangle to fill with cell rect
- Return type:
rect:
Gdk.Rectangle
Fills the bounding rectangle in bin_window coordinates for the cell at the row specified by path and the column specified by column. If path is
None
, or points to a path not currently displayed, the y and height fields of the rectangle will be filled with 0. If column isNone
, the x and width fields will be filled with 0. The sum of all cell rects does not cover the entire tree; there are extra pixels in between rows, for example. The returned rectangle is equivalent to the cell_area passed toGtk.CellRenderer.render
(). This function is only valid if self is realized.
- get_column(n)[source]¶
- Parameters:
n (
int
) – The position of the column, counting from 0.- Returns:
The
Gtk.TreeViewColumn
, orNone
if the position is outside the range of columns.- Return type:
Gets the
Gtk.TreeViewColumn
at the given position in the #tree_view.
- get_columns()[source]¶
- Returns:
A list of
Gtk.TreeViewColumn
s- Return type:
Returns a
GLib.List
of all theGtk.TreeViewColumn
s currently in self. The returned list must be freed with g_list_free ().
- get_cursor()[source]¶
- Returns:
- Return type:
(path:
Gtk.TreePath
orNone
, focus_column:Gtk.TreeViewColumn
orNone
)
Fills in path and focus_column with the current path and focus column. If the cursor isn’t currently set, then path will be
None
. If no column currently has focus, then focus_column will beNone
.The returned
Gtk.TreePath
must be freed withGtk.TreePath.free
() when you are done with it.
- get_dest_row_at_pos(drag_x, drag_y)[source]¶
- Parameters:
- Returns:
None
if there is no row at the given position or a tuple containing:- path:
the path of the highlighted row
- pos:
the drop position
- Return type:
(path:
Gtk.TreePath
orNone
, pos:Gtk.TreeViewDropPosition
) orNone
Determines the destination row for a given position. drag_x and drag_y are expected to be in widget coordinates. This function is only meaningful if self is realized. Therefore this function will always return
None
if self is not realized or does not have a model.
- get_drag_dest_row()[source]¶
- Returns:
- Return type:
(path:
Gtk.TreePath
orNone
, pos:Gtk.TreeViewDropPosition
)
Gets information about the row that is highlighted for feedback.
- get_enable_search()[source]¶
- Returns:
whether or not to let the user search interactively
- Return type:
Returns whether or not the tree allows to start interactive searching by typing in text.
- get_enable_tree_lines()[source]¶
-
Returns whether or not tree lines are drawn in self.
New in version 2.10.
- get_expander_column()[source]¶
- Returns:
The expander column.
- Return type:
Returns the column that is the current expander column. This column has the expander arrow drawn next to it.
- get_fixed_height_mode()[source]¶
-
Returns whether fixed height mode is turned on for self.
New in version 2.6.
- get_grid_lines()[source]¶
- Returns:
a
Gtk.TreeViewGridLines
value indicating which grid lines are enabled.- Return type:
Returns which grid lines are enabled in self.
New in version 2.10.
- get_hadjustment()[source]¶
- Returns:
A
Gtk.Adjustment
object, orNone
if none is currently being used.- Return type:
Gets the
Gtk.Adjustment
currently being used for the horizontal aspect.Deprecated since version 3.0: Use
Gtk.Scrollable.get_hadjustment
()
- get_headers_clickable()[source]¶
-
Returns whether all header columns are clickable.
New in version 2.10.
- get_headers_visible()[source]¶
- Returns:
Whether the headers are visible or not.
- Return type:
Returns
True
if the headers on the self are visible.
- get_hover_expand()[source]¶
-
Returns whether hover expansion mode is turned on for self.
New in version 2.6.
- get_hover_selection()[source]¶
-
Returns whether hover selection mode is turned on for self.
New in version 2.6.
- get_level_indentation()[source]¶
- Returns:
the amount of extra indentation for child levels in self. A return value of 0 means that this feature is disabled.
- Return type:
Returns the amount, in pixels, of extra indentation for child levels in self.
New in version 2.12.
- get_model()[source]¶
- Returns:
A
Gtk.TreeModel
, orNone
if none is currently being used.- Return type:
Returns the model the
Gtk.TreeView
is based on. ReturnsNone
if the model is unset.
- get_n_columns()[source]¶
- Returns:
The number of columns in the self
- Return type:
Queries the number of columns in the given self.
New in version 3.4.
- get_path_at_pos(x, y)[source]¶
- Parameters:
- Returns:
None
if the row doesn’t exist at that coordinates or a tuple containing:- path:
- column:
- cell_x:
the X coordinate relative to the cell
- cell_y:
the Y coordinate relative to the cell
- Return type:
(path:
Gtk.TreePath
orNone
, column:Gtk.TreeViewColumn
orNone
, cell_x:int
, cell_y:int
) orNone
Finds the path at the point (x, y), relative to bin_window coordinates (please see
Gtk.TreeView.get_bin_window
()). That is, x and y are relative to an events coordinates. x and y must come from an event on the self only whereevent->window == gtk_tree_view_get_bin_window ()
. It is primarily for things like popup menus. If path is non-None
, then it will be filled with theGtk.TreePath
at that point. This path should be freed withGtk.TreePath.free
(). If column is non-None
, then it will be filled with the column at that point. cell_x and cell_y return the coordinates relative to the cell background (i.e. the background_area passed toGtk.CellRenderer.render
()). This function is only meaningful if self is realized. Therefore this function will always returnFalse
if self is not realized or does not have a model.For converting widget coordinates (eg. the ones you get from
Gtk.Widget
::query-tooltip
), please seeGtk.TreeView.convert_widget_to_bin_window_coords
().
- get_reorderable()[source]¶
-
Retrieves whether the user can reorder the tree via drag-and-drop. See
Gtk.TreeView.set_reorderable
().
- get_rubber_banding()[source]¶
-
Returns whether rubber banding is turned on for self. If the selection mode is
Gtk.SelectionMode.MULTIPLE
, rubber banding will allow the user to select multiple rows by dragging the mouse.New in version 2.10.
- get_rules_hint()[source]¶
-
Gets the setting set by
Gtk.TreeView.set_rules_hint
().Deprecated since version 3.14.
- get_search_column()[source]¶
- Returns:
the column the interactive search code searches in.
- Return type:
Gets the column searched on by the interactive search code.
- get_search_entry()[source]¶
- Returns:
the entry currently in use as search entry.
- Return type:
Returns the
Gtk.Entry
which is currently in use as interactive search entry for self. In case the built-in entry is being used,None
will be returned.New in version 2.10.
- get_selection()[source]¶
- Returns:
A
Gtk.TreeSelection
object.- Return type:
Gets the
Gtk.TreeSelection
associated with self.
- get_show_expanders()[source]¶
-
Returns whether or not expanders are drawn in self.
New in version 2.12.
- get_tooltip_column()[source]¶
- Returns:
the index of the tooltip column that is currently being used, or -1 if this is disabled.
- Return type:
Returns the column of self’s model which is being used for displaying tooltips on self’s rows.
New in version 2.12.
- get_tooltip_context(x, y, keyboard_tip)[source]¶
- Parameters:
- Returns:
whether or not the given tooltip context points to a row.
- x:
the x coordinate (relative to widget coordinates)
- y:
the y coordinate (relative to widget coordinates)
- model:
a pointer to receive a
Gtk.TreeModel
orNone
- path:
a pointer to receive a
Gtk.TreePath
orNone
- iter:
a pointer to receive a
Gtk.TreeIter
orNone
- Return type:
(
bool
, x:int
, y:int
, model:Gtk.TreeModel
orNone
, path:Gtk.TreePath
, iter:Gtk.TreeIter
)
This function is supposed to be used in a
Gtk.Widget
::query-tooltip
signal handler forGtk.TreeView
. The x, y and keyboard_tip values which are received in the signal handler, should be passed to this function without modification.The return value indicates whether there is a tree view row at the given coordinates (
True
) or not (False
) for mouse tooltips. For keyboard tooltips the row returned will be the cursor row. WhenTrue
, then any of model, path and iter which have been provided will be set to point to that row and the corresponding model. x and y will always be converted to be relative to self’s bin_window if keyboard_tooltip isFalse
.New in version 2.12.
- get_vadjustment()[source]¶
- Returns:
A
Gtk.Adjustment
object, orNone
if none is currently being used.- Return type:
Gets the
Gtk.Adjustment
currently being used for the vertical aspect.Deprecated since version 3.0: Use
Gtk.Scrollable.get_vadjustment
()
- get_visible_range()[source]¶
- Returns:
Either
None
if there is no visible range or a tuple containing:- start_path:
start of region
- end_path:
end of region
- Return type:
(start_path:
Gtk.TreePath
, end_path:Gtk.TreePath
) orNone
Returns the first and last visible path. Note that there may be invisible paths in between.
New in version 2.8.
- get_visible_rect()[source]¶
- Returns:
rectangle to fill
- Return type:
visible_rect:
Gdk.Rectangle
Fills visible_rect with the currently-visible region of the buffer, in tree coordinates. Convert to bin_window coordinates with
Gtk.TreeView.convert_tree_to_bin_window_coords
(). Tree coordinates start at 0,0 for row 0 of the tree, and cover the entire scrollable area of the tree.
- insert_column(column, position)[source]¶
- Parameters:
column (
Gtk.TreeViewColumn
) – TheGtk.TreeViewColumn
to be inserted.position (
int
) – The position to insert column in.
- Returns:
The number of columns in self after insertion.
- Return type:
This inserts the column into the self at position. If position is -1, then the column is inserted at the end. If self has “fixed_height” mode enabled, then column must have its “sizing” property set to be
Gtk.TreeViewColumnSizing.FIXED
.
- insert_column_with_attributes(position, title, cell, **kwargs)[source]¶
- Parameters:
position (
int
) – The position to insert the new column intitle (
str
) – The title to set the header tocell (
Gtk.CellRenderer
) – TheGtk.CellRenderer
Creates a new
Gtk.TreeViewColumn
and inserts it into the self at position. If position is -1, then the newly created column is inserted at the end. The column is initialized with the attributes given. If self has “fixed_height” mode enabled, then the new column will have its sizing property set to beGtk.TreeViewColumnSizing.FIXED
.
- insert_column_with_data_func(position, title, cell, func, *data)[source]¶
- Parameters:
position (
int
) – Position to insert, -1 for appendtitle (
str
) – column titlecell (
Gtk.CellRenderer
) – cell renderer for columnfunc (
Gtk.TreeCellDataFunc
) – function to set attributes of cell renderer
- Returns:
number of columns in the tree view post-insert
- Return type:
Convenience function that inserts a new column into the
Gtk.TreeView
with the given cell renderer and aGtk.TreeCellDataFunc
to set cell renderer attributes (normally using data from the model). See alsoGtk.TreeViewColumn.set_cell_data_func
(),Gtk.TreeViewColumn.pack_start
(). If self has “fixed_height” mode enabled, then the new column will have its “sizing” property set to beGtk.TreeViewColumnSizing.FIXED
.
- is_blank_at_pos(x, y)[source]¶
- Parameters:
- Returns:
True
if the area at the given coordinates is blank,False
otherwise.- path:
A pointer to a
Gtk.TreePath
pointer to be filled in, orNone
- column:
A pointer to a
Gtk.TreeViewColumn
pointer to be filled in, orNone
- cell_x:
A pointer where the X coordinate relative to the cell can be placed, or
None
- cell_y:
A pointer where the Y coordinate relative to the cell can be placed, or
None
- Return type:
(
bool
, path:Gtk.TreePath
orNone
, column:Gtk.TreeViewColumn
orNone
, cell_x:int
, cell_y:int
)
Determine whether the point (x, y) in self is blank, that is no cell content nor an expander arrow is drawn at the location. If so, the location can be considered as the background. You might wish to take special action on clicks on the background, such as clearing a current selection, having a custom context menu or starting rubber banding.
The x and y coordinate that are provided must be relative to bin_window coordinates. That is, x and y must come from an event on self where
event->window == gtk_tree_view_get_bin_window ()
.For converting widget coordinates (eg. the ones you get from
Gtk.Widget
::query-tooltip
), please seeGtk.TreeView.convert_widget_to_bin_window_coords
().The path, column, cell_x and cell_y arguments will be filled in likewise as for
Gtk.TreeView.get_path_at_pos
(). Please seeGtk.TreeView.get_path_at_pos
() for more information.New in version 3.0.
- is_rubber_banding_active()[source]¶
-
Returns whether a rubber banding operation is currently being done in self.
New in version 2.12.
- map_expanded_rows(func, *data)[source]¶
- Parameters:
func (
Gtk.TreeViewMappingFunc
) – A function to be calleddata (
object
orNone
) – User data to be passed to the function.
Calls func on all expanded rows.
- move_column_after(column, base_column)[source]¶
- Parameters:
column (
Gtk.TreeViewColumn
) – TheGtk.TreeViewColumn
to be moved.base_column (
Gtk.TreeViewColumn
orNone
) – TheGtk.TreeViewColumn
to be moved relative to, orNone
.
Moves column to be after to base_column. If base_column is
None
, then column is placed in the first position.
- remove_column(column)[source]¶
- Parameters:
column (
Gtk.TreeViewColumn
) – TheGtk.TreeViewColumn
to remove.- Returns:
The number of columns in self after removing.
- Return type:
Removes column from self.
- row_activated(path, column)[source]¶
- Parameters:
path (
Gtk.TreePath
) – TheGtk.TreePath
to be activated.column (
Gtk.TreeViewColumn
) – TheGtk.TreeViewColumn
to be activated.
Activates the cell determined by path and column.
- row_expanded(path)[source]¶
- Parameters:
path (
Gtk.TreePath
) – AGtk.TreePath
to test expansion state.- Returns:
True
if #path is expanded.- Return type:
Returns
True
if the node pointed to by path is expanded in self.
- scroll_to_cell(path, column, use_align, row_align, col_align)[source]¶
- Parameters:
path (
Gtk.TreePath
orNone
) – The path of the row to move to, orNone
.column (
Gtk.TreeViewColumn
orNone
) – TheGtk.TreeViewColumn
to move horizontally to, orNone
.use_align (
bool
) – whether to use alignment arguments, orFalse
.row_align (
float
) – The vertical alignment of the row specified by path.col_align (
float
) – The horizontal alignment of the column specified by column.
Moves the alignments of self to the position specified by column and path. If column is
None
, then no horizontal scrolling occurs. Likewise, if path isNone
no vertical scrolling occurs. At a minimum, one of column or path need to be non-None
. row_align determines where the row is placed, and col_align determines where column is placed. Both are expected to be between 0.0 and 1.0. 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means center.If use_align is
False
, then the alignment arguments are ignored, and the tree does the minimum amount of work to scroll the cell onto the screen. This means that the cell will be scrolled to the edge closest to its current position. If the cell is currently visible on the screen, nothing is done.This function only works if the model is set, and path is a valid row on the model. If the model changes before the self is realized, the centered path will be modified to reflect this change.
- scroll_to_point(tree_x, tree_y)[source]¶
- Parameters:
Scrolls the tree view such that the top-left corner of the visible area is tree_x, tree_y, where tree_x and tree_y are specified in tree coordinates. The self must be realized before this function is called. If it isn’t, you probably want to be using
Gtk.TreeView.scroll_to_cell
().If either tree_x or tree_y are -1, then that direction isn’t scrolled.
- set_activate_on_single_click(single)[source]¶
-
Cause the
Gtk.TreeView
::row-activated
signal to be emitted on a single click instead of a double click.New in version 3.8.
- set_column_drag_function(func, *user_data)[source]¶
- Parameters:
Sets a user function for determining where a column may be dropped when dragged. This function is called on every column pair in turn at the beginning of a column drag to determine where a drop can take place. The arguments passed to func are: the self, the
Gtk.TreeViewColumn
being dragged, the twoGtk.TreeViewColumn
s determining the drop spot, and user_data. If either of theGtk.TreeViewColumn
arguments for the drop spot areNone
, then they indicate an edge. If func is set to beNone
, then self reverts to the default behavior of allowing all columns to be dropped everywhere.
- set_cursor(path, focus_column, start_editing)[source]¶
- Parameters:
path (
Gtk.TreePath
) – AGtk.TreePath
focus_column (
Gtk.TreeViewColumn
orNone
) – AGtk.TreeViewColumn
, orNone
start_editing (
bool
) –True
if the specified cell should start being edited.
Sets the current keyboard focus to be at path, and selects it. This is useful when you want to focus the user’s attention on a particular row. If focus_column is not
None
, then focus is given to the column specified by it. Additionally, if focus_column is specified, and start_editing isTrue
, then editing should be started in the specified cell. This function is often followed by gtk_widget_grab_focus (self) in order to give keyboard focus to the widget. Please note that editing can only happen when the widget is realized.If path is invalid for model, the current cursor (if any) will be unset and the function will return without failing.
- set_cursor_on_cell(path, focus_column, focus_cell, start_editing)[source]¶
- Parameters:
path (
Gtk.TreePath
) – AGtk.TreePath
focus_column (
Gtk.TreeViewColumn
orNone
) – AGtk.TreeViewColumn
, orNone
focus_cell (
Gtk.CellRenderer
orNone
) – AGtk.CellRenderer
, orNone
start_editing (
bool
) –True
if the specified cell should start being edited.
Sets the current keyboard focus to be at path, and selects it. This is useful when you want to focus the user’s attention on a particular row. If focus_column is not
None
, then focus is given to the column specified by it. If focus_column and focus_cell are notNone
, and focus_column contains 2 or more editable or activatable cells, then focus is given to the cell specified by focus_cell. Additionally, if focus_column is specified, and start_editing isTrue
, then editing should be started in the specified cell. This function is often followed by gtk_widget_grab_focus (self) in order to give keyboard focus to the widget. Please note that editing can only happen when the widget is realized.If path is invalid for model, the current cursor (if any) will be unset and the function will return without failing.
New in version 2.2.
- set_destroy_count_func(func, *data)[source]¶
- Parameters:
This function should almost never be used. It is meant for private use by ATK for determining the number of visible children that are removed when the user collapses a row, or a row is deleted.
Deprecated since version 3.4: Accessibility does not need the function anymore.
- set_drag_dest_row(path, pos)[source]¶
- Parameters:
path (
Gtk.TreePath
orNone
) – The path of the row to highlight, orNone
pos (
Gtk.TreeViewDropPosition
) – Specifies whether to drop before, after or into the row
Sets the row that is highlighted for feedback. If path is
None
, an existing highlight is removed.
- set_enable_search(enable_search)[source]¶
-
If enable_search is set, then the user can type in text to search through the tree interactively (this is sometimes called “typeahead find”).
Note that even if this is
False
, the user can still initiate a search using the “start-interactive-search” key binding.
- set_enable_tree_lines(enabled)[source]¶
-
Sets whether to draw lines interconnecting the expanders in self. This does not have any visible effects for lists.
New in version 2.10.
- set_expander_column(column)[source]¶
- Parameters:
column (
Gtk.TreeViewColumn
orNone
) –None
, or the column to draw the expander arrow at.
Sets the column to draw the expander arrow at. It must be in self. If column is
None
, then the expander arrow is always at the first visible column.If you do not want expander arrow to appear in your tree, set the expander column to a hidden column.
- set_fixed_height_mode(enable)[source]¶
-
Enables or disables the fixed height mode of self. Fixed height mode speeds up
Gtk.TreeView
by assuming that all rows have the same height. Only enable this option if all rows are the same height and all columns are of typeGtk.TreeViewColumnSizing.FIXED
.New in version 2.6.
- set_grid_lines(grid_lines)[source]¶
- Parameters:
grid_lines (
Gtk.TreeViewGridLines
) – aGtk.TreeViewGridLines
value indicating which grid lines to enable.
Sets which grid lines to draw in self.
New in version 2.10.
- set_hadjustment(adjustment)[source]¶
- Parameters:
adjustment (
Gtk.Adjustment
orNone
) – TheGtk.Adjustment
to set, orNone
Sets the
Gtk.Adjustment
for the current horizontal aspect.Deprecated since version 3.0: Use
Gtk.Scrollable.set_hadjustment
()
- set_hover_expand(expand)[source]¶
-
Enables or disables the hover expansion mode of self. Hover expansion makes rows expand or collapse if the pointer moves over them.
New in version 2.6.
- set_hover_selection(hover)[source]¶
-
Enables or disables the hover selection mode of self. Hover selection makes the selected row follow the pointer. Currently, this works only for the selection modes
Gtk.SelectionMode.SINGLE
andGtk.SelectionMode.BROWSE
.New in version 2.6.
- set_level_indentation(indentation)[source]¶
- Parameters:
indentation (
int
) – the amount, in pixels, of extra indentation in self.
Sets the amount of extra indentation for child levels to use in self in addition to the default indentation. The value should be specified in pixels, a value of 0 disables this feature and in this case only the default indentation will be used. This does not have any visible effects for lists.
New in version 2.12.
- set_model(model)[source]¶
- Parameters:
model (
Gtk.TreeModel
orNone
) – The model.
Sets the model for a
Gtk.TreeView
. If the self already has a model set, it will remove it before setting the new model. If model isNone
, then it will unset the old model.
- set_reorderable(reorderable)[source]¶
-
This function is a convenience function to allow you to reorder models that support the
Gtk.TreeDragSourceIface
and theGtk.TreeDragDestIface
. BothGtk.TreeStore
andGtk.ListStore
support these. If reorderable isTrue
, then the user can reorder the model by dragging and dropping rows. The developer can listen to these changes by connecting to the model’sGtk.TreeModel
::row-inserted
andGtk.TreeModel
::row-deleted
signals. The reordering is implemented by setting up the tree view as a drag source and destination. Therefore, drag and drop can not be used in a reorderable view for any other purpose.This function does not give you any degree of control over the order – any reordering is allowed. If more control is needed, you should probably handle drag and drop manually.
- set_row_separator_func(func, *data)[source]¶
- Parameters:
func (
Gtk.TreeViewRowSeparatorFunc
orNone
) – aGtk.TreeViewRowSeparatorFunc
Sets the row separator function, which is used to determine whether a row should be drawn as a separator. If the row separator function is
None
, no separators are drawn. This is the default value.New in version 2.6.
- set_rubber_banding(enable)[source]¶
-
Enables or disables rubber banding in self. If the selection mode is
Gtk.SelectionMode.MULTIPLE
, rubber banding will allow the user to select multiple rows by dragging the mouse.New in version 2.10.
- set_rules_hint(setting)[source]¶
-
Sets a hint for the theme to draw even/odd rows in the self with different colors, also known as “zebra striping”.
This function tells the GTK+ theme that the user interface for your application requires users to read across tree rows and associate cells with one another.
Do not use it just because you prefer the appearance of the ruled tree; that’s a question for the theme. Some themes will draw tree rows in alternating colors even when rules are turned off, and users who prefer that appearance all the time can choose those themes. You should call this function only as a semantic hint to the theme engine that your tree makes alternating colors useful from a functional standpoint (since it has lots of columns, generally).
Deprecated since version 3.14.
- set_search_column(column)[source]¶
- Parameters:
column (
int
) – the column of the model to search in, or -1 to disable searching
Sets column as the column where the interactive search code should search in for the current model.
If the search column is set, users can use the “start-interactive-search” key binding to bring up search popup. The enable-search property controls whether simply typing text will also start an interactive search.
Note that column refers to a column of the current model. The search column is reset to -1 when the model is changed.
- set_search_entry(entry)[source]¶
- Parameters:
entry (
Gtk.Entry
orNone
) – the entry the interactive search code of self should use orNone
Sets the entry which the interactive search code will use for this self. This is useful when you want to provide a search entry in our interface at all time at a fixed position. Passing
None
for entry will make the interactive search code use the built-in popup entry again.New in version 2.10.
- set_search_equal_func(search_equal_func, *search_user_data)[source]¶
- Parameters:
search_equal_func (
Gtk.TreeViewSearchEqualFunc
) – the compare function to use during the searchsearch_user_data (
object
orNone
) – user data to pass to search_equal_func, orNone
Sets the compare function for the interactive search capabilities; note that somewhat like strcmp() returning 0 for equality
Gtk.TreeViewSearchEqualFunc
returnsFalse
on matches.
- set_search_position_func(func, *data)[source]¶
- Parameters:
Sets the function to use when positioning the search dialog.
New in version 2.10.
- set_show_expanders(enabled)[source]¶
-
Sets whether to draw and enable expanders and indent child rows in self. When disabled there will be no expanders visible in trees and there will be no way to expand and collapse rows by default. Also note that hiding the expanders will disable the default indentation. You can set a custom indentation in this case using
Gtk.TreeView.set_level_indentation
(). This does not have any visible effects for lists.New in version 2.12.
- set_tooltip_cell(tooltip, path, column, cell)[source]¶
- Parameters:
tooltip (
Gtk.Tooltip
) – aGtk.Tooltip
path (
Gtk.TreePath
orNone
) – aGtk.TreePath
orNone
column (
Gtk.TreeViewColumn
orNone
) – aGtk.TreeViewColumn
orNone
cell (
Gtk.CellRenderer
orNone
) – aGtk.CellRenderer
orNone
Sets the tip area of tooltip to the area path, column and cell have in common. For example if path is
None
and column is set, the tip area will be set to the full area covered by column. See alsoGtk.Tooltip.set_tip_area
().Note that if path is not specified and cell is set and part of a column containing the expander, the tooltip might not show and hide at the correct position. In such cases path must be set to the current node under the mouse cursor for this function to operate correctly.
See also
Gtk.TreeView.set_tooltip_column
() for a simpler alternative.New in version 2.12.
- set_tooltip_column(column)[source]¶
- Parameters:
column (
int
) – an integer, which is a valid column number for self’s model
If you only plan to have simple (text-only) tooltips on full rows, you can use this function to have
Gtk.TreeView
handle these automatically for you. column should be set to the column in self’s model containing the tooltip texts, or -1 to disable this feature.When enabled,
Gtk.Widget
:has-tooltip
will be set toTrue
and self will connect aGtk.Widget
::query-tooltip
signal handler.Note that the signal handler sets the text with
Gtk.Tooltip.set_markup
(), so &, <, etc have to be escaped in the text.New in version 2.12.
- set_tooltip_row(tooltip, path)[source]¶
- Parameters:
tooltip (
Gtk.Tooltip
) – aGtk.Tooltip
path (
Gtk.TreePath
) – aGtk.TreePath
Sets the tip area of tooltip to be the area covered by the row at path. See also
Gtk.TreeView.set_tooltip_column
() for a simpler alternative. See alsoGtk.Tooltip.set_tip_area
().New in version 2.12.
- set_vadjustment(adjustment)[source]¶
- Parameters:
adjustment (
Gtk.Adjustment
orNone
) – TheGtk.Adjustment
to set, orNone
Sets the
Gtk.Adjustment
for the current vertical aspect.Deprecated since version 3.0: Use
Gtk.Scrollable.set_vadjustment
()
- unset_rows_drag_dest()[source]¶
Undoes the effect of
Gtk.TreeView.enable_model_drag_dest
(). Calling this method setsGtk.TreeView
:reorderable
toFalse
.
- unset_rows_drag_source()[source]¶
Undoes the effect of
Gtk.TreeView.enable_model_drag_source
(). Calling this method setsGtk.TreeView
:reorderable
toFalse
.
- do_columns_changed() virtual¶
- do_cursor_changed() virtual¶
- do_expand_collapse_cursor_row(logical, expand, open_all) virtual¶
- do_move_cursor(step, count) virtual¶
- Parameters:
step (
Gtk.MovementStep
) –count (
int
) –
- Return type:
- do_row_activated(path, column) virtual¶
- Parameters:
path (
Gtk.TreePath
) – TheGtk.TreePath
to be activated.column (
Gtk.TreeViewColumn
) – TheGtk.TreeViewColumn
to be activated.
Activates the cell determined by path and column.
- do_row_collapsed(iter, path) virtual¶
- Parameters:
iter (
Gtk.TreeIter
) –path (
Gtk.TreePath
) –
- do_row_expanded(iter, path) virtual¶
- Parameters:
iter (
Gtk.TreeIter
) –path (
Gtk.TreePath
) –
- do_test_collapse_row(iter, path) virtual¶
- Parameters:
iter (
Gtk.TreeIter
) –path (
Gtk.TreePath
) –
- Return type:
- do_test_expand_row(iter, path) virtual¶
- Parameters:
iter (
Gtk.TreeIter
) –path (
Gtk.TreePath
) –
- Return type:
Signal Details¶
- Gtk.TreeView.signals.columns_changed(tree_view)¶
- Signal Name:
columns-changed
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signal
The number of columns of the treeview has changed.
- Gtk.TreeView.signals.cursor_changed(tree_view)¶
- Signal Name:
cursor-changed
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signal
The position of the cursor (focused cell) has changed.
- Gtk.TreeView.signals.expand_collapse_cursor_row(tree_view, object, p0, p1)¶
- Gtk.TreeView.signals.move_cursor(tree_view, step, direction)¶
- Signal Name:
move-cursor
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signalstep (
Gtk.MovementStep
) – the granularity of the move, as aGtk.MovementStep
.Gtk.MovementStep.LOGICAL_POSITIONS
,Gtk.MovementStep.VISUAL_POSITIONS
,Gtk.MovementStep.DISPLAY_LINES
,Gtk.MovementStep.PAGES
andGtk.MovementStep.BUFFER_ENDS
are supported.Gtk.MovementStep.LOGICAL_POSITIONS
andGtk.MovementStep.VISUAL_POSITIONS
are treated identically.direction (
int
) – the direction to move: +1 to move forwards; -1 to move backwards. The resulting movement is undefined for all other values.
- Returns:
- Return type:
The
Gtk.TreeView
::move-cursor
signal is akeybinding signal
which gets emitted when the user presses one of the cursor keys.Applications should not connect to it, but may emit it with g_signal_emit_by_name() if they need to control the cursor programmatically. In contrast to
Gtk.TreeView.set_cursor
() andGtk.TreeView.set_cursor_on_cell
() when moving horizontallyGtk.TreeView
::move-cursor
does not reset the current selection.
- Gtk.TreeView.signals.row_activated(tree_view, path, column)¶
- Signal Name:
row-activated
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signalpath (
Gtk.TreePath
) – theGtk.TreePath
for the activated rowcolumn (
Gtk.TreeViewColumn
) – theGtk.TreeViewColumn
in which the activation occurred
The “row-activated” signal is emitted when the method
Gtk.TreeView.row_activated
() is called, when the user double clicks a treeview row with the “activate-on-single-click” property set toFalse
, or when the user single clicks a row when the “activate-on-single-click” property set toTrue
. It is also emitted when a non-editable row is selected and one of the keys: Space, Shift+Space, Return or Enter is pressed.For selection handling refer to the tree widget conceptual overview as well as
Gtk.TreeSelection
.
- Gtk.TreeView.signals.row_collapsed(tree_view, iter, path)¶
- Signal Name:
row-collapsed
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signaliter (
Gtk.TreeIter
) – the tree iter of the collapsed rowpath (
Gtk.TreePath
) – a tree path that points to the row
The given row has been collapsed (child nodes are hidden).
- Gtk.TreeView.signals.row_expanded(tree_view, iter, path)¶
- Signal Name:
row-expanded
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signaliter (
Gtk.TreeIter
) – the tree iter of the expanded rowpath (
Gtk.TreePath
) – a tree path that points to the row
The given row has been expanded (child nodes are shown).
- Gtk.TreeView.signals.select_all(tree_view)¶
- Signal Name:
select-all
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signal- Return type:
- Gtk.TreeView.signals.select_cursor_parent(tree_view)¶
- Signal Name:
select-cursor-parent
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signal- Return type:
- Gtk.TreeView.signals.select_cursor_row(tree_view, object)¶
- Signal Name:
select-cursor-row
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signalobject (
bool
) –
- Return type:
- Gtk.TreeView.signals.start_interactive_search(tree_view)¶
- Signal Name:
start-interactive-search
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signal- Return type:
- Gtk.TreeView.signals.test_collapse_row(tree_view, iter, path)¶
- Signal Name:
test-collapse-row
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signaliter (
Gtk.TreeIter
) – the tree iter of the row to collapsepath (
Gtk.TreePath
) – a tree path that points to the row
- Returns:
- Return type:
The given row is about to be collapsed (hide its children nodes). Use this signal if you need to control the collapsibility of individual rows.
- Gtk.TreeView.signals.test_expand_row(tree_view, iter, path)¶
- Signal Name:
test-expand-row
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signaliter (
Gtk.TreeIter
) – the tree iter of the row to expandpath (
Gtk.TreePath
) – a tree path that points to the row
- Returns:
- Return type:
The given row is about to be expanded (show its children nodes). Use this signal if you need to control the expandability of individual rows.
- Gtk.TreeView.signals.toggle_cursor_row(tree_view)¶
- Signal Name:
toggle-cursor-row
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signal- Return type:
- Gtk.TreeView.signals.unselect_all(tree_view)¶
- Signal Name:
unselect-all
- Flags:
- Parameters:
tree_view (
Gtk.TreeView
) – The object which received the signal- Return type:
Property Details¶
- Gtk.TreeView.props.activate_on_single_click¶
- Name:
activate-on-single-click
- Type:
- Default Value:
- Flags:
The activate-on-single-click property specifies whether the “row-activated” signal will be emitted after a single click.
New in version 3.8.
- Gtk.TreeView.props.enable_grid_lines¶
- Name:
enable-grid-lines
- Type:
- Default Value:
- Flags:
Whether grid lines should be drawn in the tree view
- Gtk.TreeView.props.enable_search¶
- Name:
enable-search
- Type:
- Default Value:
- Flags:
View allows user to search through columns interactively
- Gtk.TreeView.props.enable_tree_lines¶
- Name:
enable-tree-lines
- Type:
- Default Value:
- Flags:
Whether tree lines should be drawn in the tree view
- Gtk.TreeView.props.expander_column¶
- Name:
expander-column
- Type:
- Default Value:
- Flags:
Set the column for the expander column
- Gtk.TreeView.props.fixed_height_mode¶
- Name:
fixed-height-mode
- Type:
- Default Value:
- Flags:
Setting the
::fixed-height-mode
property toTrue
speeds upGtk.TreeView
by assuming that all rows have the same height. Only enable this option if all rows are the same height. Please seeGtk.TreeView.set_fixed_height_mode
() for more information on this option.New in version 2.4.
- Gtk.TreeView.props.headers_clickable¶
- Name:
headers-clickable
- Type:
- Default Value:
- Flags:
Column headers respond to click events
- Gtk.TreeView.props.headers_visible¶
- Name:
headers-visible
- Type:
- Default Value:
- Flags:
Show the column header buttons
- Gtk.TreeView.props.hover_expand¶
- Name:
hover-expand
- Type:
- Default Value:
- Flags:
Enables or disables the hover expansion mode of tree_view. Hover expansion makes rows expand or collapse if the pointer moves over them.
This mode is primarily intended for treeviews in popups, e.g. in
Gtk.ComboBox
orGtk.EntryCompletion
.New in version 2.6.
- Gtk.TreeView.props.hover_selection¶
- Name:
hover-selection
- Type:
- Default Value:
- Flags:
Enables or disables the hover selection mode of tree_view. Hover selection makes the selected row follow the pointer. Currently, this works only for the selection modes
Gtk.SelectionMode.SINGLE
andGtk.SelectionMode.BROWSE
.This mode is primarily intended for treeviews in popups, e.g. in
Gtk.ComboBox
orGtk.EntryCompletion
.New in version 2.6.
- Gtk.TreeView.props.level_indentation¶
- Name:
level-indentation
- Type:
- Default Value:
0
- Flags:
Extra indentation for each level.
New in version 2.12.
- Gtk.TreeView.props.model¶
- Name:
model
- Type:
- Default Value:
- Flags:
The model for the tree view
- Gtk.TreeView.props.reorderable¶
- Name:
reorderable
- Type:
- Default Value:
- Flags:
View is reorderable
- Gtk.TreeView.props.rubber_banding¶
- Name:
rubber-banding
- Type:
- Default Value:
- Flags:
Whether to enable selection of multiple items by dragging the mouse pointer
- Gtk.TreeView.props.rules_hint¶
- Name:
rules-hint
- Type:
- Default Value:
- Flags:
Sets a hint to the theme to draw rows in alternating colors.
Deprecated since version 3.14: The theme is responsible for drawing rows using zebra striping
- Gtk.TreeView.props.search_column¶
- Name:
search-column
- Type:
- Default Value:
-1
- Flags:
Model column to search through during interactive search
- Gtk.TreeView.props.show_expanders¶
- Name:
show-expanders
- Type:
- Default Value:
- Flags:
True
if the view has expanders.New in version 2.12.
- Gtk.TreeView.props.tooltip_column¶
- Name:
tooltip-column
- Type:
- Default Value:
-1
- Flags:
The column in the model containing the tooltip texts for the rows