Gtk.ColumnView

g GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget Gtk.Scrollable Gtk.Scrollable GObject.GInterface->Gtk.Scrollable GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Buildable->Gtk.Widget Gtk.ColumnView Gtk.ColumnView Gtk.ConstraintTarget->Gtk.Widget Gtk.Scrollable->Gtk.ColumnView Gtk.Widget->Gtk.ColumnView

Subclasses:

None

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Scrollable (9)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new (model)

append_column (column)

get_columns ()

get_enable_rubberband ()

get_header_factory ()

get_model ()

get_reorderable ()

get_row_factory ()

get_show_column_separators ()

get_show_row_separators ()

get_single_click_activate ()

get_sorter ()

get_tab_behavior ()

insert_column (position, column)

remove_column (column)

scroll_to (pos, column, flags, scroll)

set_enable_rubberband (enable_rubberband)

set_header_factory (factory)

set_model (model)

set_reorderable (reorderable)

set_row_factory (factory)

set_show_column_separators (show_column_separators)

set_show_row_separators (show_row_separators)

set_single_click_activate (single_click_activate)

set_tab_behavior (tab_behavior)

sort_by_column (column, direction)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9), Gtk.Scrollable (1)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1), Gtk.Scrollable (4)

Name

Type

Flags

Short Description

columns

Gio.ListModel

r/en

enable-rubberband

bool

r/w/en

header-factory

Gtk.ListItemFactory

r/w/en

model

Gtk.SelectionModel

r/w/en

reorderable

bool

r/w/en

row-factory

Gtk.ListItemFactory

r/w/en

show-column-separators

bool

r/w/en

show-row-separators

bool

r/w/en

single-click-activate

bool

r/w/en

sorter

Gtk.Sorter

r/en

tab-behavior

Gtk.ListTabBehavior

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Short Description

activate

Emitted when a row has been activated by the user, usually via activating the Gtk.ListBase|list.activate-item action.

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Class Details

class Gtk.ColumnView(**kwargs)
Bases:

Gtk.Widget, Gtk.Scrollable

Abstract:

No

Structure:

Gtk.ColumnViewClass

GtkColumnView presents a large dynamic list of items using multiple columns with headers.

GtkColumnView uses the factories of its columns to generate a cell widget for each column, for each visible item and displays them together as the row for this item.

The [property`Gtk`.ColumnView:show-row-separators] and [property`Gtk`.ColumnView:show-column-separators] properties offer a simple way to display separators between the rows or columns.

GtkColumnView allows the user to select items according to the selection characteristics of the model. For models that allow multiple selected items, it is possible to turn on *rubberband selection*, using [property`Gtk`.ColumnView:enable-rubberband].

The column view supports sorting that can be customized by the user by clicking on column headers. To set this up, the GtkSorter returned by [method`Gtk`.ColumnView.get_sorter] must be attached to a sort model for the data that the view is showing, and the columns must have sorters attached to them by calling [method`Gtk`.ColumnViewColumn.set_sorter]. The initial sort order can be set with [method`Gtk`.ColumnView.sort_by_column].

The column view also supports interactive resizing and reordering of columns, via Drag-and-Drop of the column headers. This can be enabled or disabled with the [property`Gtk`.ColumnView:reorderable] and [property`Gtk`.ColumnViewColumn:resizable] properties.

To learn more about the list widget framework, see the overview.

CSS nodes

`` columnview[.column-separators][.rich-list][.navigation-sidebar][.data-table] ├── header │ ├── <column header> ┊ ┊ │ ╰── <column header> │ ├── listview │ ┊ ╰── [rubberband] ``

GtkColumnView uses a single CSS node named columnview. It may carry the .column-separators style class, when [property`Gtk`.ColumnView:show-column-separators] property is set. Header widgets appear below a node with name header. The rows are contained in a GtkListView widget, so there is a listview node with the same structure as for a standalone GtkListView widget. If [property`Gtk`.ColumnView:show-row-separators] is set, it will be passed on to the list view, causing its CSS node to carry the .separators style class. For rubberband selection, a node with name rubberband is used.

The main columnview node may also carry style classes to select the style of list presentation : .rich-list, .navigation-sidebar or .data-table.

Accessibility

GtkColumnView uses the Gtk.AccessibleRole.TREE_GRID role, header title widgets are using the Gtk.AccessibleRole.COLUMN_HEADER role. The row widgets are using the Gtk.AccessibleRole.ROW role, and individual cells are using the Gtk.AccessibleRole.GRID_CELL role

classmethod new(model)[source]
Parameters:

model (Gtk.SelectionModel or None) – the list model to use

Returns:

a new GtkColumnView

Return type:

Gtk.Widget

Creates a new GtkColumnView.

You most likely want to call [method`Gtk`.ColumnView.append_column] to add columns next.

append_column(column)[source]
Parameters:

column (Gtk.ColumnViewColumn) – a GtkColumnViewColumn that hasn’t been added to a GtkColumnView yet

Appends the column to the end of the columns in self.

get_columns()[source]
Returns:

The list managing the columns

Return type:

Gio.ListModel

Gets the list of columns in this column view.

This list is constant over the lifetime of self and can be used to monitor changes to the columns of self by connecting to the ::items-changed signal.

get_enable_rubberband()[source]
Returns:

True if rubberband selection is enabled

Return type:

bool

Returns whether rows can be selected by dragging with the mouse.

get_header_factory()[source]
Returns:

The factory in use

Return type:

Gtk.ListItemFactory or None

Gets the factory that’s currently used to populate section headers.

New in version 4.12.

get_model()[source]
Returns:

The model in use

Return type:

Gtk.SelectionModel or None

Gets the model that’s currently used to read the items displayed.

get_reorderable()[source]
Returns:

True if columns are reorderable

Return type:

bool

Returns whether columns are reorderable.

get_row_factory()[source]
Returns:

The factory

Return type:

Gtk.ListItemFactory or None

Gets the factory set via [method`Gtk`.ColumnView.set_row_factory].

New in version 4.12.

get_show_column_separators()[source]
Returns:

True if the list shows column separators

Return type:

bool

Returns whether the list should show separators between columns.

get_show_row_separators()[source]
Returns:

True if the list shows separators

Return type:

bool

Returns whether the list should show separators between rows.

get_single_click_activate()[source]
Returns:

True if rows are activated on single click

Return type:

bool

Returns whether rows will be activated on single click and selected on hover.

get_sorter()[source]
Returns:

the GtkSorter of self

Return type:

Gtk.Sorter or None

Returns a special sorter that reflects the users sorting choices in the column view.

To allow users to customizable sorting by clicking on column headers, this sorter needs to be set on the sort model underneath the model that is displayed by the view.

See [method`Gtk`.ColumnViewColumn.set_sorter] for setting up per-column sorting.

Here is an example: ``c gtk_column_view_column_set_sorter (column, sorter); gtk_column_view_append_column (view, column); sorter = g_object_ref (gtk_column_view_get_sorter (view))); model = gtk_sort_list_model_new (store, sorter); selection = gtk_no_selection_new (model); gtk_column_view_set_model (view, selection); ``

get_tab_behavior()[source]
Returns:

The behavior of the <kbd>Tab</kbd> key

Return type:

Gtk.ListTabBehavior

Gets the behavior set for the <kbd>Tab</kbd> key.

New in version 4.12.

insert_column(position, column)[source]
Parameters:
  • position (int) – the position to insert column at

  • column (Gtk.ColumnViewColumn) – the GtkColumnViewColumn to insert

Inserts a column at the given position in the columns of self.

If column is already a column of self, it will be repositioned.

remove_column(column)[source]
Parameters:

column (Gtk.ColumnViewColumn) – a GtkColumnViewColumn that’s part of self

Removes the column from the list of columns of self.

scroll_to(pos, column, flags, scroll)[source]
Parameters:

Scroll to the row at the given position - or cell if a column is given - and performs the actions specified in flags.

This function works no matter if the listview is shown or focused. If it isn’t, then the changes will take effect once that happens.

New in version 4.12.

set_enable_rubberband(enable_rubberband)[source]
Parameters:

enable_rubberband (bool) – True to enable rubberband selection

Sets whether selections can be changed by dragging with the mouse.

set_header_factory(factory)[source]
Parameters:

factory (Gtk.ListItemFactory or None) – the factory to use

Sets the GtkListItemFactory to use for populating the [class`Gtk`.ListHeader] objects used in section headers.

If this factory is set to None, the list will not show section headers.

New in version 4.12.

set_model(model)[source]
Parameters:

model (Gtk.SelectionModel or None) – the model to use

Sets the model to use.

This must be a [iface`Gtk`.SelectionModel].

set_reorderable(reorderable)[source]
Parameters:

reorderable (bool) – whether columns should be reorderable

Sets whether columns should be reorderable by dragging.

set_row_factory(factory)[source]
Parameters:

factory (Gtk.ListItemFactory or None) – The row factory

Sets the factory used for configuring rows. The factory must be for configuring [class`Gtk`.ColumnViewRow] objects.

If this factory is not set - which is the default - then the defaults will be used.

This factory is not used to set the widgets displayed in the individual cells. For that see [method`GtkColumnViewColumn`.set_factory] and [class`GtkColumnViewCell`].

New in version 4.12.

set_show_column_separators(show_column_separators)[source]
Parameters:

show_column_separators (bool) – True to show column separators

Sets whether the list should show separators between columns.

set_show_row_separators(show_row_separators)[source]
Parameters:

show_row_separators (bool) – True to show row separators

Sets whether the list should show separators between rows.

set_single_click_activate(single_click_activate)[source]
Parameters:

single_click_activate (bool) – True to activate items on single click

Sets whether rows should be activated on single click and selected on hover.

set_tab_behavior(tab_behavior)[source]
Parameters:

tab_behavior (Gtk.ListTabBehavior) – The desired tab behavior

Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.

New in version 4.12.

sort_by_column(column, direction)[source]
Parameters:

Sets the sorting of the view.

This function should be used to set up the initial sorting. At runtime, users can change the sorting of a column view by clicking on the list headers.

This call only has an effect if the sorter returned by [method`Gtk`.ColumnView.get_sorter] is set on a sort model, and [method`Gtk`.ColumnViewColumn.set_sorter] has been called on column to associate a sorter with the column.

If column is None, the view will be unsorted.

Signal Details

Gtk.ColumnView.signals.activate(column_view, position)
Signal Name:

activate

Flags:

RUN_LAST

Parameters:
  • column_view (Gtk.ColumnView) – The object which received the signal

  • position (int) – position of item to activate

Emitted when a row has been activated by the user, usually via activating the Gtk.ListBase|list.activate-item action.

This allows for a convenient way to handle activation in a columnview. See [method`Gtk`.ListItem.set_activatable] for details on how to use this signal.

Property Details

Gtk.ColumnView.props.columns
Name:

columns

Type:

Gio.ListModel

Default Value:

None

Flags:

READABLE, EXPLICIT_NOTIFY

The list of columns.

Gtk.ColumnView.props.enable_rubberband
Name:

enable-rubberband

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Allow rubberband selection.

Gtk.ColumnView.props.header_factory
Name:

header-factory

Type:

Gtk.ListItemFactory

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Factory for creating header widgets.

New in version 4.12.

Gtk.ColumnView.props.model
Name:

model

Type:

Gtk.SelectionModel

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Model for the items displayed.

Gtk.ColumnView.props.reorderable
Name:

reorderable

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether columns are reorderable.

Gtk.ColumnView.props.row_factory
Name:

row-factory

Type:

Gtk.ListItemFactory

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The factory used for configuring rows.

New in version 4.12.

Gtk.ColumnView.props.show_column_separators
Name:

show-column-separators

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Show separators between columns.

Gtk.ColumnView.props.show_row_separators
Name:

show-row-separators

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Show separators between rows.

Gtk.ColumnView.props.single_click_activate
Name:

single-click-activate

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Activate rows on single click and select them on hover.

Gtk.ColumnView.props.sorter
Name:

sorter

Type:

Gtk.Sorter

Default Value:

None

Flags:

READABLE, EXPLICIT_NOTIFY

Sorter with the sorting choices of the user.

Gtk.ColumnView.props.tab_behavior
Name:

tab-behavior

Type:

Gtk.ListTabBehavior

Default Value:

Gtk.ListTabBehavior.ALL

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Behavior of the <kbd>Tab</kbd> key

New in version 4.12.