panel.layout.grid module#
Layout components to lay out objects in a grid.
- class panel.layout.grid.GridBox(*objects: Any, **params: Any)[source]#
Bases:
ListPanel
The GridBox is a list-like layout (unlike GridSpec) that wraps objects into a grid according to the specified nrows and ncols parameters.
It has a list-like API with methods to append, extend, clear, insert, pop, remove and __setitem__, which makes it possible to interactively update and modify the layout.
Reference: https://panel.holoviz.org/reference/layouts/GridBox.html
- Example:
>>> pn.GridBox( ... python_object_1, python_object_2, ..., ... python_object_24, ncols=6 ... )
Parameter Definitions
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingpanel.layout.base.ListLike
: objectspanel.layout.base.ListPanel
: scrollnrows = Integer(allow_None=True, bounds=(0, None), inclusive_bounds=(True, True), label='Nrows')
Number of rows to reflow the layout into.
ncols = Integer(allow_None=True, bounds=(0, None), inclusive_bounds=(True, True), label='Ncols')
Number of columns to reflow the layout into.
- class panel.layout.grid.GridSpec(*, mode, ncols, nrows, objects, loading, align, aspect_ratio, css_classes, design, height, height_policy, margin, max_height, max_width, min_height, min_width, sizing_mode, styles, stylesheets, tags, visible, width, width_policy, name)[source]#
Bases:
Panel
The GridSpec is an array like layout that allows arranging multiple Panel objects in a grid using a simple API to assign objects to individual grid cells or to a grid span.
Other layout containers function like lists, but a GridSpec has an API similar to a 2D array, making it possible to use 2D assignment to populate, index, and slice the grid.
See GridStack for a similar layout that allows the user to resize and drag the cells.
Reference: https://panel.holoviz.org/reference/layouts/GridSpec.html
- Example:
>>> import panel as pn >>> gspec = pn.GridSpec(width=800, height=600) >>> gspec[:, 0 ] = pn.Spacer(styles=dict(background='red')) >>> gspec[0, 1:3] = pn.Spacer(styles=dict(background='green')) >>> gspec[1, 2:4] = pn.Spacer(styles=dict(background='orange')) >>> gspec[2, 1:4] = pn.Spacer(styles=dict(background='blue')) >>> gspec[0:1, 3:4] = pn.Spacer(styles=dict(background='purple')) >>> gspec
- Attributes:
- grid
Methods
clone
(**params)Makes a copy of the GridSpec sharing the same parameters.
Parameter Definitions
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, margin, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visiblepanel.viewable.Viewable
: loadingobjects = ChildDict(class_=<class 'dict'>, default={}, label='Objects')
The dictionary of child objects that make up the grid.
mode = Selector(default='warn', label='Mode', names={}, objects=['warn', 'error', 'override'])
Whether to warn, error or simply override on overlapping assignment.
ncols = Integer(allow_None=True, bounds=(0, None), inclusive_bounds=(True, True), label='Ncols')
Limits the number of columns that can be assigned.
nrows = Integer(allow_None=True, bounds=(0, None), inclusive_bounds=(True, True), label='Nrows')
Limits the number of rows that can be assigned.