:right-sidebar: True ColumnViewColumn =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: ColumnViewColumn(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` ``GtkColumnViewColumn`` represents the columns being added to a ``GtkColumnView``. The main ingredient for a ``GtkColumnViewColumn`` is the ``GtkListItemFactory`` that tells the columnview how to create cells for this column from items in the model. Columns have a title, and can optionally have a header menu set with :obj:`~gi.repository.Gtk.ColumnViewColumn.set_header_menu`. A sorter can be associated with a column using :obj:`~gi.repository.Gtk.ColumnViewColumn.set_sorter`, to let users influence sorting by clicking on the column header. Constructors ------------ .. rst-class:: interim-class .. class:: ColumnViewColumn :no-index: .. classmethod:: new(title: str | None = None, factory: ~gi.repository.Gtk.ListItemFactory | None = None) -> ~gi.repository.Gtk.ColumnViewColumn Creates a new ``GtkColumnViewColumn`` that uses the given ``factory`` for mapping items to widgets. You most likely want to call :obj:`~gi.repository.Gtk.ColumnView.append_column` next. The function takes ownership of the argument, so you can write code like: .. code-block:: :dedent: column = gtk_column_view_column_new (_("Name"), gtk_builder_list_item_factory_new_from_resource ("/name.ui")); :param title: Title to use for this column :param factory: The factory to populate items with Methods ------- .. rst-class:: interim-class .. class:: ColumnViewColumn :no-index: .. method:: get_column_view() -> ~gi.repository.Gtk.ColumnView | None Gets the column view that's currently displaying this column. If ``self`` has not been added to a column view yet, :const:`None` is returned. .. method:: get_expand() -> bool Returns whether this column should expand. .. method:: get_factory() -> ~gi.repository.Gtk.ListItemFactory | None Gets the factory that's currently used to populate list items for this column. .. method:: get_fixed_width() -> int Gets the fixed width of the column. .. method:: get_header_menu() -> ~gi.repository.Gio.MenuModel | None Gets the menu model that is used to create the context menu for the column header. .. method:: get_id() -> str | None Returns the ID set with :func:`~gi.repository.Gtk.ColumnViewColumn.set_id`. .. versionadded:: 4.10 .. method:: get_resizable() -> bool Returns whether this column is resizable. .. method:: get_sorter() -> ~gi.repository.Gtk.Sorter | None Returns the sorter that is associated with the column. .. method:: get_title() -> str | None Returns the title set with :func:`~gi.repository.Gtk.ColumnViewColumn.set_title`. .. method:: get_visible() -> bool Returns whether this column is visible. .. method:: set_expand(expand: bool) -> None Sets the column to take available extra space. The extra space is shared equally amongst all columns that have the expand set to :const:`True`. :param expand: :const:`True` if this column should expand to fill available sace .. method:: set_factory(factory: ~gi.repository.Gtk.ListItemFactory | None = None) -> None Sets the ``GtkListItemFactory`` to use for populating list items for this column. :param factory: the factory to use .. method:: set_fixed_width(fixed_width: int) -> None If ``fixed_width`` is not -1, sets the fixed width of ``column``; otherwise unsets it. Setting a fixed width overrides the automatically calculated width. Interactive resizing also sets the “fixed-width” property. :param fixed_width: the new fixed width, or -1 .. method:: set_header_menu(menu: ~gi.repository.Gio.MenuModel | None = None) -> None Sets the menu model that is used to create the context menu for the column header. :param menu: a ``GMenuModel`` .. method:: set_id(id: str | None = None) -> None Sets the id of this column. GTK makes no use of this, but applications can use it when storing column view configuration. It is up to callers to ensure uniqueness of IDs. .. versionadded:: 4.10 :param id: ID to use for this column .. method:: set_resizable(resizable: bool) -> None Sets whether this column should be resizable by dragging. :param resizable: whether this column should be resizable .. method:: set_sorter(sorter: ~gi.repository.Gtk.Sorter | None = None) -> None Associates a sorter with the column. If ``sorter`` is :const:`None`, the column will not let users change the sorting by clicking on its header. This sorter can be made active by clicking on the column header, or by calling :obj:`~gi.repository.Gtk.ColumnView.sort_by_column`. See :obj:`~gi.repository.Gtk.ColumnView.get_sorter` for the necessary steps for setting up customizable sorting for :obj:`~gi.repository.Gtk.ColumnView`. :param sorter: the ``GtkSorter`` to associate with ``column`` .. method:: set_title(title: str | None = None) -> None Sets the title of this column. The title is displayed in the header of a ``GtkColumnView`` for this column and is therefore user-facing text that should be translated. :param title: Title to use for this column .. method:: set_visible(visible: bool) -> None Sets whether this column should be visible in views. :param visible: whether this column should be visible Properties ---------- .. rst-class:: interim-class .. class:: ColumnViewColumn :no-index: .. attribute:: props.column_view :type: ~gi.repository.Gtk.ColumnView The ``GtkColumnView`` this column is a part of. .. attribute:: props.expand :type: bool Column gets share of extra width allocated to the view. .. attribute:: props.factory :type: ~gi.repository.Gtk.ListItemFactory Factory for populating list items. .. attribute:: props.fixed_width :type: int If not -1, this is the width that the column is allocated, regardless of the size of its content. .. attribute:: props.header_menu :type: ~gi.repository.Gio.MenuModel Menu model used to create the context menu for the column header. .. attribute:: props.id :type: str An ID for the column. GTK is not currently using the ID for anything, but it can be used by applications when saving column view configurations. It is up to applications to ensure uniqueness of IDs. .. versionadded:: 4.10 .. attribute:: props.resizable :type: bool Whether this column is resizable. .. attribute:: props.sorter :type: ~gi.repository.Gtk.Sorter Sorter for sorting items according to this column. .. attribute:: props.title :type: str Title displayed in the header. .. attribute:: props.visible :type: bool Whether this column is visible.