GridSpec#

This component is also available in the classic reference.

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.

Use pn.ui.GridSpec to create this component.

API#

.. py:class:: 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) :module: panel.layout.grid

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**
       ..

   **ncols**
       ..

   **nrows**
       ..

.. rubric:: Methods

.. autosummary::

  clone

.. !! processed by numpydoc !!

Parameter Definitions


Parameters inherited from:

   :class:`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, visible

   :class:`panel.viewable.Viewable`: loading

objects = 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.

.. py:method:: GridSpec.clone(**params) :module: panel.layout.grid

  Makes a copy of the GridSpec sharing the same parameters.


  :Parameters:

      **params: Keyword arguments override the parameters on the clone.**
          ..



  :Returns:

      Cloned GridSpec object
          ..











  ..
      !! processed by numpydoc !!