Gtk.TreeViewColumn

g GObject.GInterface GObject.GInterface Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.CellLayout Gtk.CellLayout GObject.GInterface->Gtk.CellLayout GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.TreeViewColumn Gtk.TreeViewColumn GObject.InitiallyUnowned->Gtk.TreeViewColumn GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Buildable->Gtk.TreeViewColumn Gtk.CellLayout->Gtk.TreeViewColumn

Subclasses:

None

Methods

Inherited:

GObject.Object (37), Gtk.Buildable (1), Gtk.CellLayout (9)

Structs:

GObject.ObjectClass (5)

class

new ()

class

new_with_area (area)

add_attribute (cell_renderer, attribute, column)

cell_get_position (cell_renderer)

cell_get_size ()

cell_is_visible ()

cell_set_cell_data (tree_model, iter, is_expander, is_expanded)

clear ()

clear_attributes (cell_renderer)

clicked ()

focus_cell (cell)

get_alignment ()

get_button ()

get_clickable ()

get_expand ()

get_fixed_width ()

get_max_width ()

get_min_width ()

get_reorderable ()

get_resizable ()

get_sizing ()

get_sort_column_id ()

get_sort_indicator ()

get_sort_order ()

get_spacing ()

get_title ()

get_tree_view ()

get_visible ()

get_widget ()

get_width ()

get_x_offset ()

pack_end (cell, expand)

pack_start (cell, expand)

queue_resize ()

set_alignment (xalign)

set_attributes (cell_renderer, **attributes)

set_cell_data_func (cell_renderer, func, *func_data)

set_clickable (clickable)

set_expand (expand)

set_fixed_width (fixed_width)

set_max_width (max_width)

set_min_width (min_width)

set_reorderable (reorderable)

set_resizable (resizable)

set_sizing (type)

set_sort_column_id (sort_column_id)

set_sort_indicator (setting)

set_sort_order (order)

set_spacing (spacing)

set_title (title)

set_visible (visible)

set_widget (widget)

Virtual Methods

Inherited:

GObject.Object (7), Gtk.Buildable (9), Gtk.CellLayout (9)

Properties

Name

Type

Flags

Short Description

alignment

float

r/w/en

cell-area

Gtk.CellArea

r/w/co

clickable

bool

r/w/en

expand

bool

r/w/en

fixed-width

int

r/w/en

max-width

int

r/w/en

min-width

int

r/w/en

reorderable

bool

r/w/en

resizable

bool

r/w/en

sizing

Gtk.TreeViewColumnSizing

r/w/en

sort-column-id

int

r/w/en

sort-indicator

bool

r/w/en

sort-order

Gtk.SortType

r/w/en

spacing

int

r/w/en

title

str

r/w

visible

bool

r/w/en

widget

Gtk.Widget

r/w

width

int

r

x-offset

int

r

Signals

Inherited:

GObject.Object (1)

Name

Short Description

clicked

Emitted when the column’s header has been clicked.

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk.TreeViewColumn(title='', cell_renderer=None, **attributes)
Bases:

GObject.InitiallyUnowned, Gtk.Buildable, Gtk.CellLayout

Abstract:

No

A visible column in a [class`Gtk`.TreeView] widget

The GtkTreeViewColumn object represents a visible column in a GtkTreeView widget. It allows to set properties of the column header, and functions as a holding pen for the cell renderers which determine how the data in the column is displayed.

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, and to the [class`Gtk`.TreeView] documentation for specifics about the CSS node structure for treeviews and their headers.

Deprecated since version 4.10: Use [class`Gtk`.ColumnView] and [class`Gtk`.ColumnViewColumn] instead of [class`Gtk`.TreeView] to show a tabular list

classmethod new()[source]
Returns:

A newly created GtkTreeViewColumn.

Return type:

Gtk.TreeViewColumn

Creates a new GtkTreeViewColumn.

Deprecated since version 4.10: Use Gtk.ColumnView instead

classmethod new_with_area(area)[source]
Parameters:

area (Gtk.CellArea) – the GtkCellArea that the newly created column should use to layout cells.

Returns:

A newly created GtkTreeViewColumn.

Return type:

Gtk.TreeViewColumn

Creates a new GtkTreeViewColumn using area to render its cells.

Deprecated since version 4.10: Use Gtk.ColumnView instead

add_attribute(cell_renderer, attribute, column)[source]
Parameters:
  • cell_renderer (Gtk.CellRenderer) – the GtkCellRenderer to set attributes on

  • attribute (str) – An attribute on the renderer

  • column (int) – The column position on the model to get the attribute from.

Adds an attribute mapping to the list in self.

The column is the column of the model to get a value from, and the attribute is the parameter on cell_renderer to be set from the value. So for example if column 2 of the model contains strings, you could have the “text” attribute of a GtkCellRendererText get its values from column 2.

Deprecated since version 4.10: Use Gtk.ColumnView instead

cell_get_position(cell_renderer)[source]
Parameters:

cell_renderer (Gtk.CellRenderer) – a Gtk.CellRenderer

Returns:

None if cell does not belong to self or a tuple containing:

x_offset:

the horizontal position of cell within self

width:

the width of cell

Return type:

(x_offset: int, width: int) or None

Obtains the horizontal position and size of a cell in a column. If the cell is not found in the column None is returned.

Deprecated since version 4.10: Use Gtk.ColumnView instead

cell_get_size()[source]
Returns:

x_offset:

location to return x offset of a cell relative to cell_area

y_offset:

location to return y offset of a cell relative to cell_area

width:

location to return width needed to render a cell

height:

location to return height needed to render a cell

Return type:

(x_offset: int, y_offset: int, width: int, height: int)

Obtains the width and height needed to render the column. This is used primarily by the GtkTreeView.

Deprecated since version 4.10: Use Gtk.ColumnView instead

cell_is_visible()[source]
Returns:

True, if any of the cells packed into the self are currently visible

Return type:

bool

Returns True if any of the cells packed into the self are visible. For this to be meaningful, you must first initialize the cells with Gtk.TreeViewColumn.cell_set_cell_data()

Deprecated since version 4.10: Use Gtk.ColumnView instead

cell_set_cell_data(tree_model, iter, is_expander, is_expanded)[source]
Parameters:
  • tree_model (Gtk.TreeModel) – The GtkTreeModel to get the cell renderers attributes from.

  • iter (Gtk.TreeIter) – The GtkTreeIter to get the cell renderer’s attributes from.

  • is_expander (bool) – True, if the row has children

  • is_expanded (bool) – True, if the row has visible children

Sets the cell renderer based on the tree_model and iter. That is, for every attribute mapping in self, it will get a value from the set column on the iter, and use that value to set the attribute on the cell renderer. This is used primarily by the GtkTreeView.

Deprecated since version 4.10: Use Gtk.ColumnView instead

clear()[source]

Unsets all the mappings on all renderers on the self.

Deprecated since version 4.10: Use Gtk.ColumnView instead

clear_attributes(cell_renderer)[source]
Parameters:

cell_renderer (Gtk.CellRenderer) – a GtkCellRenderer to clear the attribute mapping on.

Clears all existing attributes previously set with Gtk.TreeViewColumn.set_attributes().

Deprecated since version 4.10: Use Gtk.ColumnView instead

clicked()[source]

Emits the “clicked” signal on the column. This function will only work if self is clickable.

Deprecated since version 4.10: Use Gtk.ColumnView instead

focus_cell(cell)[source]
Parameters:

cell (Gtk.CellRenderer) – A GtkCellRenderer

Sets the current keyboard focus to be at cell, if the column contains 2 or more editable and activatable cells.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_alignment()[source]
Returns:

The current alignent of self.

Return type:

float

Returns the current x alignment of self. This value can range between 0.0 and 1.0.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_button()[source]
Returns:

The button for the column header.

Return type:

Gtk.Widget

Returns the button used in the treeview column header

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_clickable()[source]
Returns:

True if user can click the column header.

Return type:

bool

Returns True if the user can click on the header for the column.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_expand()[source]
Returns:

True if the column expands to fill available space.

Return type:

bool

Returns True if the column expands to fill available space.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_fixed_width()[source]
Returns:

The fixed width of the column.

Return type:

int

Gets the fixed width of the column. This may not be the actual displayed width of the column; for that, use Gtk.TreeViewColumn.get_width().

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_max_width()[source]
Returns:

The maximum width of the self.

Return type:

int

Returns the maximum width in pixels of the self, or -1 if no maximum width is set.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_min_width()[source]
Returns:

The minimum width of the self.

Return type:

int

Returns the minimum width in pixels of the self, or -1 if no minimum width is set.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_reorderable()[source]
Returns:

True if the self can be reordered by the user.

Return type:

bool

Returns True if the self can be reordered by the user.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_resizable()[source]
Returns:

True, if the self can be resized.

Return type:

bool

Returns True if the self can be resized by the end user.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_sizing()[source]
Returns:

The type of self.

Return type:

Gtk.TreeViewColumnSizing

Returns the current type of self.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_sort_column_id()[source]
Returns:

the current sort_column_id for this column, or -1 if this column can’t be used for sorting

Return type:

int

Gets the logical sort_column_id that the model sorts on when this column is selected for sorting.

See [method`Gtk`.TreeViewColumn.set_sort_column_id].

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_sort_indicator()[source]
Returns:

whether the sort indicator arrow is displayed

Return type:

bool

Gets the value set by Gtk.TreeViewColumn.set_sort_indicator().

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_sort_order()[source]
Returns:

the sort order the sort indicator is indicating

Return type:

Gtk.SortType

Gets the value set by Gtk.TreeViewColumn.set_sort_order().

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_spacing()[source]
Returns:

the spacing of self.

Return type:

int

Returns the spacing of self.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_title()[source]
Returns:

the title of the column. This string should not be modified or freed.

Return type:

str

Returns the title of the widget.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_tree_view()[source]
Returns:

The tree view wherein column has been inserted

Return type:

Gtk.Widget or None

Returns the GtkTreeView wherein self has been inserted. If column is currently not inserted in any tree view, None is returned.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_visible()[source]
Returns:

whether the column is visible or not. If it is visible, then the tree will show the column.

Return type:

bool

Returns True if self is visible.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_widget()[source]
Returns:

The GtkWidget in the column header

Return type:

Gtk.Widget or None

Returns the GtkWidget in the button on the column header.

If a custom widget has not been set then None is returned.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_width()[source]
Returns:

The current width of self.

Return type:

int

Returns the current size of self in pixels.

Deprecated since version 4.10: Use Gtk.ColumnView instead

get_x_offset()[source]
Returns:

The current X offset of self.

Return type:

int

Returns the current X offset of self in pixels.

Deprecated since version 4.10: Use Gtk.ColumnView instead

pack_end(cell, expand)[source]
Parameters:
  • cell (Gtk.CellRenderer) – The GtkCellRenderer

  • expand (bool) – True if cell is to be given extra space allocated to self.

Adds the cell to end of the column. If expand is False, then the cell is allocated no more space than it needs. Any unused space is divided evenly between cells for which expand is True.

Deprecated since version 4.10: Use Gtk.ColumnView instead

pack_start(cell, expand)[source]
Parameters:
  • cell (Gtk.CellRenderer) – The GtkCellRenderer

  • expand (bool) – True if cell is to be given extra space allocated to self.

Packs the cell into the beginning of the column. If expand is False, then the cell is allocated no more space than it needs. Any unused space is divided evenly between cells for which expand is True.

Deprecated since version 4.10: Use Gtk.ColumnView instead

queue_resize()[source]

Flags the column, and the cell renderers added to this column, to have their sizes renegotiated.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_alignment(xalign)[source]
Parameters:

xalign (float) – The alignment, which is between [0.0 and 1.0] inclusive.

Sets the alignment of the title or custom widget inside the column header. The alignment determines its location inside the button – 0.0 for left, 0.5 for center, 1.0 for right.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_attributes(cell_renderer, **attributes)[source]
Parameters:

cell_renderer (Gtk.CellRenderer) – the Gtk.CellRenderer we’re setting the attributes of

Sets the attributes in the list as the attributes of self.

The attributes should be in attribute/column order, as in Gtk.TreeViewColumn.add_attribute(). All existing attributes are removed, and replaced with the new attributes.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_cell_data_func(cell_renderer, func, *func_data)[source]
Parameters:

Sets the GtkTreeCellDataFunc to use for the column.

This function is used instead of the standard attributes mapping for setting the column value, and should set the value of self's cell renderer as appropriate. func may be None to remove an older one.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_clickable(clickable)[source]
Parameters:

clickable (bool) – True if the header is active.

Sets the header to be active if clickable is True. When the header is active, then it can take keyboard focus, and can be clicked.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_expand(expand)[source]
Parameters:

expand (bool) – True if the column should expand to fill available space.

Sets the column to take available extra space. This space is shared equally amongst all columns that have the expand set to True. If no column has this option set, then the last column gets all extra space. By default, every column is created with this False.

Along with “fixed-width”, the “expand” property changes when the column is resized by the user.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_fixed_width(fixed_width)[source]
Parameters:

fixed_width (int) – The new fixed width, in pixels, or -1.

If fixed_width is not -1, sets the fixed width of self; otherwise unsets it. The effective value of fixed_width is clamped between the minimum and maximum width of the column; however, the value stored in the “fixed-width” property is not clamped. If the column sizing is Gtk.TreeViewColumnSizing.GROW_ONLY or Gtk.TreeViewColumnSizing.AUTOSIZE, setting a fixed width overrides the automatically calculated width. Note that fixed_width is only a hint to GTK; the width actually allocated to the column may be greater or less than requested.

Along with “expand”, the “fixed-width” property changes when the column is resized by the user.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_max_width(max_width)[source]
Parameters:

max_width (int) – The maximum width of the column in pixels, or -1.

Sets the maximum width of the self. If max_width is -1, then the maximum width is unset. Note, the column can actually be wider than max width if it’s the last column in a view. In this case, the column expands to fill any extra space.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_min_width(min_width)[source]
Parameters:

min_width (int) – The minimum width of the column in pixels, or -1.

Sets the minimum width of the self. If min_width is -1, then the minimum width is unset.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_reorderable(reorderable)[source]
Parameters:

reorderable (bool) – True, if the column can be reordered.

If reorderable is True, then the column can be reordered by the end user dragging the header.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_resizable(resizable)[source]
Parameters:

resizable (bool) – True, if the column can be resized

If resizable is True, then the user can explicitly resize the column by grabbing the outer edge of the column button.

If resizable is True and sizing mode of the column is Gtk.TreeViewColumnSizing.AUTOSIZE, then the sizing mode is changed to Gtk.TreeViewColumnSizing.GROW_ONLY.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_sizing(type)[source]
Parameters:

type (Gtk.TreeViewColumnSizing) – The ``GtkTreeViewColumn``Sizing.

Sets the growth behavior of self to type.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_sort_column_id(sort_column_id)[source]
Parameters:

sort_column_id (int) – The sort_column_id of the model to sort on.

Sets the logical sort_column_id that this column sorts on when this column is selected for sorting. Doing so makes the column header clickable.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_sort_indicator(setting)[source]
Parameters:

setting (bool) – True to display an indicator that the column is sorted

Call this function with a setting of True to display an arrow in the header button indicating the column is sorted. Call Gtk.TreeViewColumn.set_sort_order() to change the direction of the arrow.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_sort_order(order)[source]
Parameters:

order (Gtk.SortType) – sort order that the sort indicator should indicate

Changes the appearance of the sort indicator.

This does not actually sort the model. Use Gtk.TreeViewColumn.set_sort_column_id() if you want automatic sorting support. This function is primarily for custom sorting behavior, and should be used in conjunction with Gtk.TreeSortable.set_sort_column_id() to do that. For custom models, the mechanism will vary.

The sort indicator changes direction to indicate normal sort or reverse sort. Note that you must have the sort indicator enabled to see anything when calling this function; see Gtk.TreeViewColumn.set_sort_indicator().

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_spacing(spacing)[source]
Parameters:

spacing (int) – distance between cell renderers in pixels.

Sets the spacing field of self, which is the number of pixels to place between cell renderers packed into it.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_title(title)[source]
Parameters:

title (str) – The title of the self.

Sets the title of the self. If a custom widget has been set, then this value is ignored.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_visible(visible)[source]
Parameters:

visible (bool) – True if the self is visible.

Sets the visibility of self.

Deprecated since version 4.10: Use Gtk.ColumnView instead

set_widget(widget)[source]
Parameters:

widget (Gtk.Widget or None) – A child GtkWidget

Sets the widget in the header to be widget. If widget is None, then the header button is set with a GtkLabel set to the title of self.

Deprecated since version 4.10: Use Gtk.ColumnView instead

Signal Details

Gtk.TreeViewColumn.signals.clicked(tree_view_column)
Signal Name:

clicked

Flags:

RUN_LAST

Parameters:

tree_view_column (Gtk.TreeViewColumn) – The object which received the signal

Emitted when the column’s header has been clicked.

Property Details

Gtk.TreeViewColumn.props.alignment
Name:

alignment

Type:

float

Default Value:

0.0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.cell_area
Name:

cell-area

Type:

Gtk.CellArea

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The GtkCellArea used to layout cell renderers for this column.

If no area is specified when creating the tree view column with Gtk.TreeViewColumn.new_with_area() a horizontally oriented GtkCellAreaBox will be used.

Gtk.TreeViewColumn.props.clickable
Name:

clickable

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.expand
Name:

expand

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.fixed_width
Name:

fixed-width

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.max_width
Name:

max-width

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.min_width
Name:

min-width

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.reorderable
Name:

reorderable

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.resizable
Name:

resizable

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.sizing
Name:

sizing

Type:

Gtk.TreeViewColumnSizing

Default Value:

Gtk.TreeViewColumnSizing.GROW_ONLY

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.sort_column_id
Name:

sort-column-id

Type:

int

Default Value:

-1

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Logical sort column ID this column sorts on when selected for sorting. Setting the sort column ID makes the column header clickable. Set to -1 to make the column unsortable.

Gtk.TreeViewColumn.props.sort_indicator
Name:

sort-indicator

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.sort_order
Name:

sort-order

Type:

Gtk.SortType

Default Value:

Gtk.SortType.ASCENDING

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.spacing
Name:

spacing

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.title
Name:

title

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE

Gtk.TreeViewColumn.props.visible
Name:

visible

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Gtk.TreeViewColumn.props.widget
Name:

widget

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE

Gtk.TreeViewColumn.props.width
Name:

width

Type:

int

Default Value:

0

Flags:

READABLE

Gtk.TreeViewColumn.props.x_offset
Name:

x-offset

Type:

int

Default Value:

0

Flags:

READABLE