panel.layout.base module#
Defines Layout classes which may be used to arrange panes and widgets in flexible ways to build complex dashboards.
- class panel.layout.base.Column(*objects: Any, **params: Any)[source]#
Bases:
ListPanel
The Column layout allows arranging multiple panel objects in a vertical container.
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/Column.html
- Example:
>>> pn.Column(some_widget, some_pane, some_python_object)
Methods
scroll_to
(index)Scrolls to the child at the provided index.
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
: scrollauto_scroll_limit = Integer(bounds=(0, None), default=0, inclusive_bounds=(True, True), label='Auto scroll limit')
Max pixel distance from the latest object in the Column to activate automatic scrolling upon update. Setting to 0 disables auto-scrolling.
scroll_button_threshold = Integer(bounds=(0, None), default=0, inclusive_bounds=(True, True), label='Scroll button threshold')
Min pixel distance from the latest object in the Column to display the scroll button. Setting to 0 disables the scroll button.
scroll_position = Integer(default=0, inclusive_bounds=(True, True), label='Scroll position')
Current scroll position of the Column. Setting this value will update the scroll position of the Column. Setting to 0 will scroll to the top.
view_latest = Boolean(default=False, label='View latest')
Whether to scroll to the latest object on init. If not enabled the view will be on the first object.
- class panel.layout.base.ListLike(*objects: Any, **params: Any)[source]#
Bases:
Parameterized
Methods
append
(obj)Appends an object to the layout.
clear
()Clears the objects on this layout.
clone
(*objects, **params)Makes a copy of the layout sharing the same parameters.
extend
(objects)Extends the objects on this layout with a list.
index
(object)Returns the integer index of the supplied object in the list of objects.
insert
(index, obj)Inserts an object in the layout at the specified index.
pop
(index)Pops an item from the layout by index.
remove
(obj)Removes an object from the layout.
reverse
()Reverses the objects in the layout.
Parameter Definitions
objects = Children(allow_refs=True, bounds=(0, None), class_=<class 'panel.viewable.Viewable'>, default=[], item_type=<class 'panel.viewable.Viewable'>, label='Objects')
The list of child objects that make up the layout.
- append(obj: Any) None [source]#
Appends an object to the layout.
- Parameters:
- obj (object): Panel component to add to the layout.
- clear() list[Viewable] [source]#
Clears the objects on this layout.
- Returns:
- objects (list[Viewable]): List of cleared objects.
- clone(*objects: Any, **params: Any) ListLike [source]#
Makes a copy of the layout sharing the same parameters.
- Parameters:
- objects: Objects to add to the cloned layout.
- params: Keyword arguments override the parameters on the clone.
- Returns:
- Cloned layout object
- extend(objects: Iterable[Any]) None [source]#
Extends the objects on this layout with a list.
- Parameters:
- objects (list): List of panel components to add to the layout.
- index(object) int [source]#
Returns the integer index of the supplied object in the list of objects.
- Parameters:
- obj (object): Panel component to look up the index for.
- Returns:
- index (int): Integer index of the object in the layout.
- insert(index: int, obj: Any) None [source]#
Inserts an object in the layout at the specified index.
- Parameters:
- index (int): Index at which to insert the object.
- object (object): Panel components to insert in the layout.
- pop(index: int) Viewable [source]#
Pops an item from the layout by index.
- Parameters:
- index (int): The index of the item to pop from the layout.
- class panel.layout.base.ListPanel(*objects: Any, **params: Any)[source]#
-
An abstract baseclass for Panel objects with list-like children.
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
: objectsscroll = Selector(allow_refs=True, default=False, label='Scroll', names={}, objects=[False, True, 'both-auto', 'y-auto', 'x-auto', 'both', 'x', 'y'])
Whether to add scrollbars if the content overflows the size of the container. If “both-auto”, will only add scrollbars if the content overflows in either directions. If “x-auto” or “y-auto”, will only add scrollbars if the content overflows in the respective direction. If “both”, will always add scrollbars. If “x” or “y”, will always add scrollbars in the respective direction. If False, overflowing content will be clipped. If True, will only add scrollbars in the direction of the container, (e.g. Column: vertical, Row: horizontal).
- class panel.layout.base.NamedListLike(*items: list[Any | tuple[str, Any]], **params: Any)[source]#
Bases:
Parameterized
Methods
append
(pane)Appends an object to the tabs.
clear
()Clears the tabs.
clone
(*objects, **params)Makes a copy of the Tabs sharing the same parameters.
extend
(panes)Extends the the tabs with a list.
insert
(index, pane)Inserts an object in the tabs at the specified index.
pop
(index)Pops an item from the tabs by index.
remove
(pane)Removes an object from the tabs.
reverse
()Reverses the tabs.
Parameter Definitions
objects = Children(bounds=(0, None), class_=<class 'panel.viewable.Viewable'>, default=[], item_type=<class 'panel.viewable.Viewable'>, label='Objects')
The list of child objects that make up the layout.
- append(pane: Any) None [source]#
Appends an object to the tabs.
- Parameters:
- obj (object): Panel component to add as a tab.
- clone(*objects: Any, **params: Any) NamedListLike [source]#
Makes a copy of the Tabs sharing the same parameters.
- Parameters:
- objects: Objects to add to the cloned Tabs object.
- params: Keyword arguments override the parameters on the clone.
- Returns:
- Cloned Tabs object
- extend(panes: Iterable[Any]) None [source]#
Extends the the tabs with a list.
- Parameters:
- objects (list): List of panel components to add as tabs.
- insert(index: int, pane: Any) None [source]#
Inserts an object in the tabs at the specified index.
- Parameters:
- index (int): Index at which to insert the object.
- object (object): Panel components to insert as tabs.
- pop(index: int) Viewable [source]#
Pops an item from the tabs by index.
- Parameters:
- index (int): The index of the item to pop from the tabs.
- class panel.layout.base.NamedListPanel(*items: list[Any | tuple[str, Any]], **params: Any)[source]#
Bases:
NamedListLike
,Panel
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.NamedListLike
: objectsactive = Integer(bounds=(0, None), default=0, inclusive_bounds=(True, True), label='Active')
Index of the currently displayed objects.
scroll = Selector(default=False, label='Scroll', names={}, objects=[False, True, 'both-auto', 'y-auto', 'x-auto', 'both', 'x', 'y'])
Whether to add scrollbars if the content overflows the size of the container. If “both-auto”, will only add scrollbars if the content overflows in either directions. If “x-auto” or “y-auto”, will only add scrollbars if the content overflows in the respective direction. If “both”, will always add scrollbars. If “x” or “y”, will always add scrollbars in the respective direction. If False, overflowing content will be clipped. If True, will only add scrollbars in the direction of the container, (e.g. Column: vertical, Row: horizontal).
- class panel.layout.base.Panel(refs=None, **params)[source]#
Bases:
Reactive
Abstract baseclass for a layout of Viewables.
Methods
get_root
([doc, comm, preprocess])Returns the root model and applies pre-processing hooks
select
([selector])Iterates over the Viewable and any potential children in the applying the Selector.
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
: loading- get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model [source]#
Returns the root model and applies pre-processing hooks
- Parameters:
- doc: bokeh.Document
Bokeh document the bokeh model will be attached to.
- comm: pyviz_comms.Comm
Optional pyviz_comms when working in notebook
- preprocess: boolean (default=True)
Whether to run preprocessing hooks
- Returns:
- Returns the bokeh model corresponding to this panel object
- select(selector=None)[source]#
Iterates over the Viewable and any potential children in the applying the Selector.
- Parameters:
- selector: type or callable or None
The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.
- Returns:
- viewables: list(Viewable)
- class panel.layout.base.Row(*objects: Any, **params: Any)[source]#
Bases:
ListPanel
The Row layout allows arranging multiple panel objects in a horizontal container.
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/Row.html
- Example:
>>> pn.Row(some_widget, some_pane, some_python_object)
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
: scroll
- class panel.layout.base.WidgetBox(*objects: Any, **params: Any)[source]#
Bases:
ListPanel
The WidgetBox layout allows arranging multiple panel objects in a vertical (or horizontal) container.
It is largely identical to the Column layout, but has some default styling that makes widgets be clearly grouped together visually.
It has a list-like API with methods to append, extend, clear, insert, pop, remove and __setitem__, which make it possible to interactively update and modify the layout.
Reference: https://panel.holoviz.org/reference/layouts/WidgetBox.html
- Example:
>>> pn.WidgetBox(some_widget, another_widget)
Parameter Definitions
Parameters inherited from:
panel.viewable.Layoutable
: align, aspect_ratio, 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
: scrollcss_classes = List(bounds=(0, None), default=['panel-widget-box'], label='Css classes', nested_refs=True)
CSS classes to apply to the layout.
disabled = Boolean(default=False, label='Disabled')
Whether the widget is disabled.
horizontal = Boolean(default=False, label='Horizontal')
Whether to lay out the widgets in a Row layout as opposed to a Column layout.