bokeh.models.layouts

Various kinds of layout components.

class Box(*args, **kwargs)[source]

Bases: bokeh.models.layouts.LayoutDOM

Abstract base class for Row and Column. Do not use directly.

Note

This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

children

property type: List ( Instance ( LayoutDOM ) )

The list of children, which can be other components including plots, rows, columns, and widgets.

spacing

property type: Int

The gap between children (in pixels).

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "children": [],
  "css_classes": [],
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "id": "12435",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "margin": [
    0,
    0,
    0,
    0
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "sizing_mode": null,
  "spacing": 0,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}
class Column(*args, **kwargs)[source]

Bases: bokeh.models.layouts.Box

Lay out child components in a single vertical row.

Children can be specified as positional arguments, as a single argument that is a sequence, or using the children keyword argument.

rows

property type: Either ( Either ( Enum ( Enumeration(auto, min, fit, max) ), Int ), Dict ( Either ( Int , String ), Either ( Either ( Enum ( Enumeration(auto, min, fit, max) ), Int ), Struct , Struct , Struct ) ) )

Describes how the component should maintain its rows’ heights.

Note

This is an experimental feature and may change in future. Use it at your own discretion.

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "children": [],
  "css_classes": [],
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "id": "12438",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "margin": [
    0,
    0,
    0,
    0
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "rows": "auto",
  "sizing_mode": null,
  "spacing": 0,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}
class GridBox(**kwargs)[source]

Bases: bokeh.models.layouts.LayoutDOM

children

property type: List ( Either ( Tuple ( Instance ( LayoutDOM ), Int , Int ), Tuple ( Instance ( LayoutDOM ), Int , Int , Int , Int ) ) )

A list of children with their associated position in the grid (row, column).

cols

property type: Either ( Either ( Enum ( Enumeration(auto, min, fit, max) ), Int ), Dict ( Either ( Int , String ), Either ( Either ( Enum ( Enumeration(auto, min, fit, max) ), Int ), Struct , Struct , Struct ) ) )

Describes how the grid should maintain its columns’ widths.

Note

This is an experimental feature and may change in future. Use it at your own discretion.

rows

property type: Either ( Either ( Enum ( Enumeration(auto, min, fit, max) ), Int ), Dict ( Either ( Int , String ), Either ( Either ( Enum ( Enumeration(auto, min, fit, max) ), Int ), Struct , Struct , Struct ) ) )

Describes how the grid should maintain its rows’ heights.

Note

This is an experimental feature and may change in future. Use it at your own discretion.

spacing

property type: Either ( Int , Tuple ( Int , Int ) )

The gap between children (in pixels).

Either a number, if spacing is the same for both dimensions, or a pair of numbers indicating spacing in the vertical and horizontal dimensions respectively.

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "children": [],
  "cols": "auto",
  "css_classes": [],
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "id": "12440",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "margin": [
    0,
    0,
    0,
    0
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "rows": "auto",
  "sizing_mode": null,
  "spacing": 0,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}
class HTMLBox(**kwargs)[source]

Bases: bokeh.models.layouts.LayoutDOM

A component which size is determined by its HTML content.

Note

This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "css_classes": [],
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "id": "12445",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "margin": [
    0,
    0,
    0,
    0
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "sizing_mode": null,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}
class LayoutDOM(**kwargs)[source]

Bases: bokeh.model.Model

The base class for layoutable components.

Note

This is an abstract base class used to help organize the hierarchy of Bokeh model types. It is not useful to instantiate on its own.

align

property type: Either ( Enum ( Align ), Tuple ( Enum ( Align ), Enum ( Align ) ) )

The alignment point within the parent container.

This property is useful only if this component is a child element of a layout (e.g. a grid). Self alignment can be overridden by the parent container (e.g. grid track align).

aspect_ratio

property type: Either ( Enum ( Enumeration(auto) ), Float )

Describes the proportional relationship between component’s width and height.

This works if any of component’s dimensions are flexible in size. If set to a number, width / height = aspect_ratio relationship will be maintained. Otherwise, if set to "auto", component’s preferred width and height will be used to determine the aspect (if not set, no aspect will be preserved).

background

property type: Color

Background color of the component.

css_classes

property type: List ( String )

A list of CSS class names to add to this DOM element. Note: the class names are simply added as-is, no other guarantees are provided.

It is also permissible to assign from tuples, however these are adapted – the property will always contain a list.

disabled

property type: Bool

Whether the widget will be disabled when rendered.

If True, the widget will be greyed-out and not responsive to UI events.

height

property type: NonNegativeInt

The height of the component (in pixels).

This can be either fixed or preferred height, depending on height sizing policy.

height_policy

property type: Either ( Auto , Enum ( SizingPolicy ) )

Describes how the component should maintain its height.

"auto"

Use component’s preferred sizing policy.

"fixed"

Use exactly height pixels. Component will overflow if it can’t fit in the available vertical space.

"fit"

Use component’s preferred height (if set) and allow to fit into the available vertical space withing the minimum and maximum height bounds (if set). Component’s height neither will be aggressively minimized nor maximized.

"min"

Use as little vertical space as possible, not less than the minimum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.

"max"

Use as much vertical space as possible, not more than the maximum height (if set). The starting point is the preferred height (if set). The height of the component may shrink or grow depending on the parent layout, aspect management and other factors.

Note

This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode if this level of control isn’t strictly necessary.

margin

property type: Tuple ( Int , Int , Int , Int )

Allows to create additional space around the component.

max_height

property type: NonNegativeInt

Minimal height of the component (in pixels) if height is adjustable.

max_width

property type: NonNegativeInt

Minimal width of the component (in pixels) if width is adjustable.

min_height

property type: NonNegativeInt

Minimal height of the component (in pixels) if height is adjustable.

min_width

property type: NonNegativeInt

Minimal width of the component (in pixels) if width is adjustable.

sizing_mode

property type: Enum ( SizingMode )

How the component should size itself.

This is a high-level setting for maintaining width and height of the component. To gain more fine grained control over sizing, use width_policy, height_policy and aspect_ratio instead (those take precedence over sizing_mode).

Possible scenarios:

"fixed"

Component is not responsive. It will retain its original width and height regardless of any subsequent browser window resize events.

"stretch_width"

Component will responsively resize to stretch to the available width, without maintaining any aspect ratio. The height of the component depends on the type of the component and may be fixed or fit to component’s contents.

"stretch_height"

Component will responsively resize to stretch to the available height, without maintaining any aspect ratio. The width of the component depends on the type of the component and may be fixed or fit to component’s contents.

"stretch_both"

Component is completely responsive, independently in width and height, and will occupy all the available horizontal and vertical space, even if this changes the aspect ratio of the component.

"scale_width"

Component will responsively resize to stretch to the available width, while maintaining the original or provided aspect ratio.

"scale_height"

Component will responsively resize to stretch to the available height, while maintaining the original or provided aspect ratio.

"scale_both"

Component will responsively resize to both the available width and height, while maintaining the original or provided aspect ratio.

visible

property type: Bool

Whether the component will be visible and a part of a layout.

width

property type: NonNegativeInt

The width of the component (in pixels).

This can be either fixed or preferred width, depending on width sizing policy.

width_policy

property type: Either ( Auto , Enum ( SizingPolicy ) )

Describes how the component should maintain its width.

"auto"

Use component’s preferred sizing policy.

"fixed"

Use exactly width pixels. Component will overflow if it can’t fit in the available horizontal space.

"fit"

Use component’s preferred width (if set) and allow it to fit into the available horizontal space within the minimum and maximum width bounds (if set). Component’s width neither will be aggressively minimized nor maximized.

"min"

Use as little horizontal space as possible, not less than the minimum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.

"max"

Use as much horizontal space as possible, not more than the maximum width (if set). The starting point is the preferred width (if set). The width of the component may shrink or grow depending on the parent layout, aspect management and other factors.

Note

This is an experimental feature and may change in future. Use it at your own discretion. Prefer using sizing_mode if this level of control isn’t strictly necessary.

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "css_classes": [],
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "id": "12446",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "margin": [
    0,
    0,
    0,
    0
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "sizing_mode": null,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}
class Row(*args, **kwargs)[source]

Bases: bokeh.models.layouts.Box

Lay out child components in a single horizontal row.

Children can be specified as positional arguments, as a single argument that is a sequence, or using the children keyword argument.

cols

property type: Either ( Either ( Enum ( Enumeration(auto, min, fit, max) ), Int ), Dict ( Either ( Int , String ), Either ( Either ( Enum ( Enumeration(auto, min, fit, max) ), Int ), Struct , Struct , Struct ) ) )

Describes how the component should maintain its columns’ widths.

Note

This is an experimental feature and may change in future. Use it at your own discretion.

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "children": [],
  "cols": "auto",
  "css_classes": [],
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "id": "12463",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "margin": [
    0,
    0,
    0,
    0
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "sizing_mode": null,
  "spacing": 0,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}
class Spacer(**kwargs)[source]

Bases: bokeh.models.layouts.LayoutDOM

A container for space used to fill an empty spot in a row or column.

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "css_classes": [],
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "id": "12465",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "margin": [
    0,
    0,
    0,
    0
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "sizing_mode": null,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}
class WidgetBox(*args, **kwargs)[source]

Bases: bokeh.models.layouts.Column

Create a column of bokeh widgets with predefined styling.

JSON Prototype
{
  "align": "start",
  "aspect_ratio": null,
  "background": null,
  "children": [],
  "css_classes": [],
  "disabled": false,
  "height": null,
  "height_policy": "auto",
  "id": "12466",
  "js_event_callbacks": {},
  "js_property_callbacks": {},
  "margin": [
    0,
    0,
    0,
    0
  ],
  "max_height": null,
  "max_width": null,
  "min_height": null,
  "min_width": null,
  "name": null,
  "rows": "auto",
  "sizing_mode": null,
  "spacing": 0,
  "subscribed_events": [],
  "tags": [],
  "visible": true,
  "width": null,
  "width_policy": "auto"
}