ColumnView

class ColumnView(**properties: Any)

Superclasses: Widget, InitiallyUnowned, Object

Implemented Interfaces: Accessible, Buildable, ConstraintTarget, Scrollable

Constructors:

ColumnView(**properties)
new(model:Gtk.SelectionModel=None) -> Gtk.Widget

Constructors

class ColumnView
classmethod new(model: SelectionModel | None = None) Widget

Creates a new GtkColumnView.

You most likely want to call append_column to add columns next.

Parameters:

model – the list model to use

Methods

class ColumnView
append_column(column: ColumnViewColumn) None

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

Parameters:

column – a GtkColumnViewColumn that hasn’t been added to a GtkColumnView yet

get_columns() 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() bool

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

get_header_factory() ListItemFactory | None

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

Added in version 4.12.

get_model() SelectionModel | None

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

get_reorderable() bool

Returns whether columns are reorderable.

get_row_factory() ListItemFactory | None

Gets the factory set via set_row_factory.

Added in version 4.12.

get_show_column_separators() bool

Returns whether the list should show separators between columns.

get_show_row_separators() bool

Returns whether the list should show separators between rows.

get_single_click_activate() bool

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

get_sorter() Sorter | 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 set_sorter for setting up per-column sorting.

Here is an example:

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() ListTabBehavior

Gets the behavior set for the Tab key.

Added in version 4.12.

insert_column(position: int, column: ColumnViewColumn) None

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

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

Parameters:
  • position – the position to insert column at

  • column – the GtkColumnViewColumn to insert

remove_column(column: ColumnViewColumn) None

Removes the column from the list of columns of self.

Parameters:

column – a GtkColumnViewColumn that’s part of self

scroll_to(pos: int, column: ColumnViewColumn | None, flags: ListScrollFlags, scroll: ScrollInfo | None = None) None

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.

Added in version 4.12.

Parameters:
  • pos – position of the item

  • column – The column to scroll to or None to not scroll columns.

  • flags – actions to perform

  • scroll – details of how to perform the scroll operation or None to scroll into view

set_enable_rubberband(enable_rubberband: bool) None

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

Parameters:

enable_rubberbandTrue to enable rubberband selection

set_header_factory(factory: ListItemFactory | None = None) None

Sets the GtkListItemFactory to use for populating the ListHeader objects used in section headers.

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

Added in version 4.12.

Parameters:

factory – the factory to use

set_model(model: SelectionModel | None = None) None

Sets the model to use.

This must be a SelectionModel.

Parameters:

model – the model to use

set_reorderable(reorderable: bool) None

Sets whether columns should be reorderable by dragging.

Parameters:

reorderable – whether columns should be reorderable

set_row_factory(factory: ListItemFactory | None = None) None

Sets the factory used for configuring rows. The factory must be for configuring 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 set_factory and GtkColumnViewCell.

Added in version 4.12.

Parameters:

factory – The row factory

set_show_column_separators(show_column_separators: bool) None

Sets whether the list should show separators between columns.

Parameters:

show_column_separatorsTrue to show column separators

set_show_row_separators(show_row_separators: bool) None

Sets whether the list should show separators between rows.

Parameters:

show_row_separatorsTrue to show row separators

set_single_click_activate(single_click_activate: bool) None

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

Parameters:

single_click_activateTrue to activate items on single click

set_tab_behavior(tab_behavior: ListTabBehavior) None

Sets the behavior of the Tab and Shift`+:kbd:`Tab keys.

Added in version 4.12.

Parameters:

tab_behavior – The desired tab behavior

sort_by_column(column: ColumnViewColumn | None, direction: SortType) None

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 get_sorter is set on a sort model, and set_sorter has been called on column to associate a sorter with the column.

If column is None, the view will be unsorted.

Parameters:
  • column – the GtkColumnViewColumn to sort by

  • direction – the direction to sort in

Properties

class ColumnView
props.columns: ListModel

The list of columns.

props.enable_rubberband: bool

Allow rubberband selection.

props.header_factory: ListItemFactory

Factory for creating header widgets.

Added in version 4.12.

props.model: SelectionModel

Model for the items displayed.

props.reorderable: bool

Whether columns are reorderable.

props.row_factory: ListItemFactory

The factory used for configuring rows.

Added in version 4.12.

props.show_column_separators: bool

Show separators between columns.

props.show_row_separators: bool

Show separators between rows.

props.single_click_activate: bool

Activate rows on single click and select them on hover.

props.sorter: Sorter

Sorter with the sorting choices of the user.

props.tab_behavior: ListTabBehavior

Behavior of the Tab key

Added in version 4.12.

Signals

class ColumnView.signals
activate(position: int) None

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

This allows for a convenient way to handle activation in a columnview. See set_activatable for details on how to use this signal.

Parameters:

position – position of item to activate