Gtk.GridView¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Orientable (2), Gtk.Scrollable (9)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
|||
r/w/en |
Signals¶
- Inherited:
Name |
Short Description |
---|---|
Emitted when a cell has been activated by the user, usually via activating the |
Fields¶
- Inherited:
Class Details¶
- class Gtk.GridView(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
GtkGridView
presents a large dynamic grid of items.GtkGridView
uses its factory to generate one child widget for each visible item and shows them in a grid. The orientation of the grid view determines if the grid reflows vertically or horizontally.GtkGridView
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`.GridView:enable-rubberband].To learn more about the list widget framework, see the overview.
- CSS nodes
`` gridview ├── child[.activatable] │ ├── child[.activatable] │ ┊ ╰── [rubberband] ``
GtkGridView
uses a single CSS node with namegridview
. Each child uses a single CSS node with namechild
. If the [property`Gtk`.ListItem:activatable] property is set, the corresponding row will have the.activatable
style class. For rubberband selection, a subnode with namerubberband
is used.- Accessibility
GtkGridView
uses theGtk.AccessibleRole.GRID
role, and the items use theGtk.AccessibleRole.GRID_CELL
role.- classmethod new(model, factory)[source]¶
- Parameters:
model (
Gtk.SelectionModel
orNone
) – the model to usefactory (
Gtk.ListItemFactory
orNone
) – The factory to populate items with
- Returns:
a new
GtkGridView
using the given model and factory- Return type:
Creates a new
GtkGridView
that uses the given factory for mapping items to widgets.The function takes ownership of the arguments, so you can write code like ``c grid_view = gtk_grid_view_new (create_model (),
gtk_builder_list_item_factory_new_from_resource (“/resource.ui”));
- get_factory()[source]¶
- Returns:
The factory in use
- Return type:
Gets the factory that’s currently used to populate list items.
- get_max_columns()[source]¶
- Returns:
The maximum number of columns
- Return type:
Gets the maximum number of columns that the grid will use.
- get_min_columns()[source]¶
- Returns:
The minimum number of columns
- Return type:
Gets the minimum number of columns that the grid will use.
- get_model()[source]¶
- Returns:
The model in use
- Return type:
Gets the model that’s currently used to read the items displayed.
- get_single_click_activate()[source]¶
-
Returns whether items will be activated on single click and selected on hover.
- get_tab_behavior()[source]¶
- Returns:
The behavior of the <kbd>Tab</kbd> key
- Return type:
Gets the behavior set for the <kbd>Tab</kbd> key.
New in version 4.12.
- scroll_to(pos, flags, scroll)[source]¶
- Parameters:
pos (
int
) – position of the itemflags (
Gtk.ListScrollFlags
) – actions to performscroll (
Gtk.ScrollInfo
orNone
) – details of how to perform the scroll operation orNone
to scroll into view
Scrolls to the item at the given position and performs the actions specified in flags.
This function works no matter if the gridview 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]¶
-
Sets whether selections can be changed by dragging with the mouse.
- set_factory(factory)[source]¶
- Parameters:
factory (
Gtk.ListItemFactory
orNone
) – the factory to use
Sets the
GtkListItemFactory
to use for populating list items.
- set_max_columns(max_columns)[source]¶
- Parameters:
max_columns (
int
) – The maximum number of columns
Sets the maximum number of columns to use.
This number must be at least 1.
If max_columns is smaller than the minimum set via [method`Gtk`.GridView.set_min_columns], that value is used instead.
- set_min_columns(min_columns)[source]¶
- Parameters:
min_columns (
int
) – The minimum number of columns
Sets the minimum number of columns to use.
This number must be at least 1.
If min_columns is smaller than the minimum set via [method`Gtk`.GridView.set_max_columns], that value is ignored.
- set_model(model)[source]¶
- Parameters:
model (
Gtk.SelectionModel
orNone
) – the model to use
Sets the model to use.
This must be a [iface`Gtk`.SelectionModel].
- set_single_click_activate(single_click_activate)[source]¶
-
Sets whether items 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.
Signal Details¶
- Gtk.GridView.signals.activate(grid_view, position)¶
- Signal Name:
activate
- Flags:
- Parameters:
grid_view (
Gtk.GridView
) – The object which received the signalposition (
int
) – position of item to activate
Emitted when a cell has been activated by the user, usually via activating the
Gtk.GridView
|list.activate-item action.This allows for a convenient way to handle activation in a gridview. See [property`Gtk`.ListItem:activatable] for details on how to use this signal.
Property Details¶
- Gtk.GridView.props.enable_rubberband¶
- Name:
enable-rubberband
- Type:
- Default Value:
- Flags:
Allow rubberband selection.
- Gtk.GridView.props.factory¶
- Name:
factory
- Type:
- Default Value:
- Flags:
Factory for populating list items.
- Gtk.GridView.props.max_columns¶
- Name:
max-columns
- Type:
- Default Value:
7
- Flags:
Maximum number of columns per row.
If this number is smaller than [property`Gtk`.GridView:min-columns], that value is used instead.
- Gtk.GridView.props.min_columns¶
- Name:
min-columns
- Type:
- Default Value:
1
- Flags:
Minimum number of columns per row.
- Gtk.GridView.props.model¶
- Name:
model
- Type:
- Default Value:
- Flags:
Model for the items displayed.
- Gtk.GridView.props.single_click_activate¶
- Name:
single-click-activate
- Type:
- Default Value:
- Flags:
Activate rows on single click and select them on hover.
- Gtk.GridView.props.tab_behavior¶
- Name:
tab-behavior
- Type:
- Default Value:
- Flags:
Behavior of the <kbd>Tab</kbd> key
New in version 4.12.