ListView
Superclasses: ListBase
, Widget
, InitiallyUnowned
, Object
Implemented Interfaces: Accessible
, Buildable
, ConstraintTarget
, Orientable
, Scrollable
- Constructors:
ListView(**properties)
new(model:Gtk.SelectionModel=None, factory:Gtk.ListItemFactory=None) -> Gtk.Widget
Constructors
- class ListView
- classmethod new(model: SelectionModel | None = None, factory: ListItemFactory | None = None) Widget
Creates a new
GtkListView
that uses the givenfactory
for mapping items to widgets.The function takes ownership of the arguments, so you can write code like
list_view = gtk_list_view_new (create_model (), gtk_builder_list_item_factory_new_from_resource ("/resource.ui"));
- Parameters:
model – the model to use
factory – The factory to populate items with
Methods
- class ListView
-
- get_factory() ListItemFactory | None
Gets the factory that’s currently used to populate list items.
- 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_single_click_activate() bool
Returns whether rows will be activated on single click and selected on hover.
- get_tab_behavior() ListTabBehavior
Gets the behavior set for the Tab key.
Added in version 4.12.
- scroll_to(pos: int, flags: ListScrollFlags, scroll: ScrollInfo | None = None) None
Scrolls to the item at the given position 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
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_rubberband –
True
to enable rubberband selection
- set_factory(factory: ListItemFactory | None = None) None
Sets the
GtkListItemFactory
to use for populating list items.- Parameters:
factory – the factory to use
- set_header_factory(factory: ListItemFactory | None = None) None
Sets the
GtkListItemFactory
to use for populating theListHeader
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
to use.- Parameters:
model – the model to use
- set_show_separators(show_separators: bool) None
Sets whether the list box should show separators between rows.
- Parameters:
show_separators –
True
to show 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_activate –
True
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
Properties
- class ListView
-
- props.factory: ListItemFactory
Factory for populating list items.
- props.header_factory: ListItemFactory
Factory for creating header widgets.
Added in version 4.12.
- props.model: SelectionModel
Model for the items displayed.
- props.tab_behavior: ListTabBehavior
Behavior of the Tab key
Added in version 4.12.
Signals
- class ListView.signals
- activate(position: int) None
Emitted when a row has been activated by the user, usually via activating the GtkListView|list.activate-item action.
This allows for a convenient way to handle activation in a listview. See
set_activatable
for details on how to use this signal.- Parameters:
position – position of item to activate