panel.models Package#


models Package#

The models module defines custom bokeh models which extend upon the functionality that is provided in bokeh by default. The models are defined as pairs of Python classes and TypeScript models defined in .ts files.


ace Module#

Inheritance diagram of panel.models.ace

Defines custom AcePlot bokeh model to render Ace editor.

class panel.models.ace.AcePlot(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLBox

A Bokeh model that wraps around a Ace editor and renders it inside a Bokeh plot.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


browser Module#

Inheritance diagram of panel.models.browser

This module provides a Bokeh BrowserInfo Model exposing the browser window and navigator APIs.

class panel.models.browser.BrowserInfo(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Model

A python wrapper around the JS window and navigator APIs.

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

property document: Document | None#

The |Document| this model is attached to (can be None)

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)

chatarea_input Module#

Inheritance diagram of panel.models.chatarea_input
class panel.models.chatarea_input.ChatAreaInput(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: TextAreaInput

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

auto_grow#

Whether the text area should automatically grow vertically to accommodate the current text.

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

cols#

20

Type:

Specifies the width of the text area (in average character width). Default

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

description#

Either a plain text or a tooltip with a rich HTML description of the function of this widget.

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

disabled_enter#

If True, disables sending the message by pressing the enter_sends key.

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

enter_sends#

If True, pressing the Enter key sends the message, if False it is sent by pressing Ctrl+Enter

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_length#

Max count of characters in field

max_rows#

Maximum number of rows the input area can grow to if auto_grow is enabled.

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

placeholder#

Placeholder for empty input field.

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

rows#

2

Type:

Specifies the height of the text area (in lines). Default

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

title#

Widget’s label.

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
value#

Initial or entered text value.

Change events are triggered whenever <enter> is pressed.

value_input#

Initial or current value.

Change events are triggered whenever any update happens, i.e. on every keypress.

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.chatarea_input.ChatMessageEvent(model, value=None)[source]#

Bases: ModelEvent


comm_manager Module#

Inheritance diagram of panel.models.comm_manager
class panel.models.comm_manager.CommManager(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Model

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

property document: Document | None#

The |Document| this model is attached to (can be None)

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)

datetime_picker Module#

Inheritance diagram of panel.models.datetime_picker
class panel.models.datetime_picker.DatetimePicker(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: InputWidget

Calendar-based date picker widget.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

description#

Either a plain text or a tooltip with a rich HTML description of the function of this widget.

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

disabled_dates#

A list of dates of (start, end) date ranges to make unavailable for selection. All other dates will be available.

Note

Only one of disabled_dates and enabled_dates should be specified.

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

enabled_dates#

A list of dates of (start, end) date ranges to make available for selection. All other dates will be unavailable.

Note

Only one of disabled_dates and enabled_dates should be specified.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

inline#

Whether the calendar sholud be displayed inline.

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_date#

Optional latest allowable date.

max_height#

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

max_width#

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

min_date#

Optional earliest allowable date.

min_height#

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

min_width#

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

mode#

Should either be “single” or “range”.

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

position#

Where the calendar is rendered relative to the input when inline is False.

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

title#

Widget’s label.

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
value#

The initial or picked date.

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


deckgl Module#

Inheritance diagram of panel.models.deckgl

Defines a custom DeckGLPlot to render DeckGL Plots

[Deck.gl](https://deck.gl/#/) is an awesome WebGL-powered framework for visual exploratory data analysis of large datasets.

And now DeckGL provides Python bindings. See

class panel.models.deckgl.DeckGLPlot(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLBox

A Bokeh model that wraps around a DeckGL plot and renders it inside a HTMLBox

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


echarts Module#

Inheritance diagram of panel.models.echarts

Defines custom bokeh model to render ECharts plots.

class panel.models.echarts.ECharts(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: LayoutDOM

A Bokeh model that wraps around an ECharts plot and renders it inside a Bokeh.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.echarts.EChartsEvent(model, type=None, data=None, query=None)[source]#

Bases: ModelEvent


enums Module#

Declares enumerations for various model properties.


feed Module#

Inheritance diagram of panel.models.feed
class panel.models.feed.Feed(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Column

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

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.

children#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

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#

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.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

spacing#

The gap between children (in pixels).

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
view_latest#

Whether to scroll to the latest object on init. If not enabled the view will be on the first object.

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.feed.ScrollButtonClick(model, data=None)[source]#

Bases: ModelEvent


icon Module#

Inheritance diagram of panel.models.icon
class panel.models.icon.ButtonIcon(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: _ClickableIcon, AbstractButton

A ButtonIcon is a clickable icon that toggles between an active and inactive state and keeps track of the number of times it has been clicked.

active_icon#

The name of the icon to display when toggled.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

button_type#

A style for the button, signifying it’s role. Possible values are one of the following:

clicks#

The number of times the button has been clicked.

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

icon#

The name of the icon or SVG to display.

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
label#

Either HTML or plain text label for the button to display.

classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

size#

The size of the icon as a valid CSS font-size.

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

title#

The title of the icon.

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

toggle_duration#

The number of milliseconds the active_icon should be shown for and how long the button should be disabled for.

tooltip#

A tooltip with plain text or rich HTML contents, providing general help or description of a widget’s or component’s function.

tooltip_delay#

Delay (in milliseconds) to display the tooltip after the cursor has hovered over the Button, default is 500ms.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
value#

Whether the icon is toggled on or off.

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.icon.ToggleIcon(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: _ClickableIcon

A ToggleIcon is a clickable icon that toggles between an active and inactive state.

active_icon#

The name of the icon to display when toggled.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

icon#

The name of the icon or SVG to display.

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

size#

The size of the icon as a valid CSS font-size.

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

title#

The title of the icon.

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

tooltip#

A tooltip with plain text or rich HTML contents, providing general help or description of a widget’s or component’s function.

tooltip_delay#

Delay (in milliseconds) to display the tooltip after the cursor has hovered over the Button, default is 500ms.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
value#

Whether the icon is toggled on or off.

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


ipywidget Module#

Inheritance diagram of panel.models.ipywidget

jsoneditor Module#

Inheritance diagram of panel.models.jsoneditor

Custom bokeh Markup models.

class panel.models.jsoneditor.JSONEditEvent(model, data=None)[source]#

Bases: ModelEvent

class panel.models.jsoneditor.JSONEditor(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLBox

A bokeh model that allows editing JSON.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


katex Module#

Inheritance diagram of panel.models.katex

Defines a custom KaTeX bokeh model to render text using KaTeX.

class panel.models.katex.KaTeX(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Markup

A bokeh model that renders text using KaTeX.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disable_math#

Whether the contents should not be processed as TeX/LaTeX input.

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text#

The text or HTML contents of the widget.

Note

If the HTML content contains elements which size depends on on external, asynchronously loaded resources, the size of the widget may be computed incorrectly. This is in particular an issue with images (<img>). To remedy this problem, one either has to set explicit dimensions using CSS properties, HTML attributes or model’s width and height properties, or inline images’ contents using data URIs.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


layout Module#

Inheritance diagram of panel.models.layout
class panel.models.layout.Card(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Column

active_header_background#

Background color of active Card header.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

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.

button_css_classes#

CSS classes to add to the Card collapse button.

children#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

collapsed#

Whether the Card is collapsed.

collapsible#

Whether the Card should have a button to collapse it.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

header_background#

Background color of the Card header.

header_color#

Color of the header text and button.

header_css_classes#

CSS classes to add to the Card header.

header_tag#

HTML tag to use for the Card header.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

hide_header#

Whether to hide the Card header

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

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#

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.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

spacing#

The gap between children (in pixels).

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tag#

CSS class to use for the Card as a whole.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
view_latest#

Whether to scroll to the latest object on init. If not enabled the view will be on the first object.

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.layout.Column(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Column

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

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.

children#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

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#

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.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

spacing#

The gap between children (in pixels).

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
view_latest#

Whether to scroll to the latest object on init. If not enabled the view will be on the first object.

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


location Module#

Inheritance diagram of panel.models.location

This module provides a Bokeh Location Model as a wrapper around the JS window.location api

class panel.models.location.Location(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Model

A python wrapper around the JS window.location api. See https://www.w3schools.com/js/js_window_location.asp and https://www.w3.org/TR/html52/browsers.html#the-location-interface

You can use this model to provide (parts of) the app state to the user as a bookmarkable and shareable link.

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

property document: Document | None#

The |Document| this model is attached to (can be None)

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

hash#

hash in window.location e.g. ‘#interact’

hostname#

hostname in window.location e.g. ‘panel.holoviz.org’

href#

80?color=blue#interact’

Type:

The full url, e.g. ‘https

Type:

//localhost

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

pathname#

pathname in window.location e.g. ‘/user_guide/Interact.html’

port#

port in window.location e.g. 80

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

protocol#

protocol in window.location e.g. ‘https’

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

reload#

Reload the page when the location is updated. For multipage apps this should be set to True, For single page apps this should be set to False

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

search#

search in window.location e.g. ‘?color=blue’

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)

markup Module#

Inheritance diagram of panel.models.markup

Custom bokeh Markup models.

class panel.models.markup.HTML(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Markup

A bokeh model to render HTML markup including embedded script tags.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disable_math#

Whether the contents should not be processed as TeX/LaTeX input.

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

run_scripts#

Whether to run scripts defined within the HTML

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text#

The text or HTML contents of the widget.

Note

If the HTML content contains elements which size depends on on external, asynchronously loaded resources, the size of the widget may be computed incorrectly. This is in particular an issue with images (<img>). To remedy this problem, one either has to set explicit dimensions using CSS properties, HTML attributes or model’s width and height properties, or inline images’ contents using data URIs.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.markup.JSON(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Markup

A bokeh model that renders JSON as tree.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

depth#

Depth to which the JSON tree is expanded.

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disable_math#

Whether the contents should not be processed as TeX/LaTeX input.

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

hover_preview#

Whether to show a hover preview for collapsed nodes.

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text#

The text or HTML contents of the widget.

Note

If the HTML content contains elements which size depends on on external, asynchronously loaded resources, the size of the widget may be computed incorrectly. This is in particular an issue with images (<img>). To remedy this problem, one either has to set explicit dimensions using CSS properties, HTML attributes or model’s width and height properties, or inline images’ contents using data URIs.

theme#

Whether to expand all JSON nodes.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.markup.PDF(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Markup

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disable_math#

Whether the contents should not be processed as TeX/LaTeX input.

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

embed#

Whether to embed the file

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

start_page#

Start page of the pdf, by default the first page.

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text#

The text or HTML contents of the widget.

Note

If the HTML content contains elements which size depends on on external, asynchronously loaded resources, the size of the widget may be computed incorrectly. This is in particular an issue with images (<img>). To remedy this problem, one either has to set explicit dimensions using CSS properties, HTML attributes or model’s width and height properties, or inline images’ contents using data URIs.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


mathjax Module#

Inheritance diagram of panel.models.mathjax

Defines a custom MathJax bokeh model to render text using MathJax.

class panel.models.mathjax.MathJax(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Markup

A bokeh model that renders text using MathJax.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disable_math#

Whether the contents should not be processed as TeX/LaTeX input.

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

text#

The text or HTML contents of the widget.

Note

If the HTML content contains elements which size depends on on external, asynchronously loaded resources, the size of the widget may be computed incorrectly. This is in particular an issue with images (<img>). To remedy this problem, one either has to set explicit dimensions using CSS properties, HTML attributes or model’s width and height properties, or inline images’ contents using data URIs.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


perspective Module#

Inheritance diagram of panel.models.perspective
class panel.models.perspective.PerspectiveClickEvent(model, config, column_names, row)[source]#

Bases: ModelEvent


plotly Module#

Inheritance diagram of panel.models.plotly

Defines a custom PlotlyPlot bokeh model to render Plotly plots.

class panel.models.plotly.PlotlyEvent(model, data=None)[source]#

Bases: ModelEvent

class panel.models.plotly.PlotlyPlot(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: LayoutDOM

A bokeh model that wraps around a plotly plot and renders it inside a bokeh plot.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


quill Module#

Inheritance diagram of panel.models.quill
class panel.models.quill.QuillInput(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLBox

WYSIWYG text editor based on Quill.js

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


reactive_html Module#

Inheritance diagram of panel.models.reactive_html
class panel.models.reactive_html.DOMEvent(model, node=None, data=None)[source]#

Bases: ModelEvent

class panel.models.reactive_html.ReactiveHTMLParser(cls, template=True)[source]#

Bases: HTMLParser

close()[source]#

Handle any buffered data.

feed(data)[source]#

Feed data to the parser.

Call this as often as you want, with as little or as much text as you want (may include ‘n’).

get_starttag_text()[source]#

Return full source of start tag: ‘<…>’.

getpos()[source]#

Return current line number and offset.

reset()[source]#

Reset this instance. Loses all unprocessed data.


speech_to_text Module#

Inheritance diagram of panel.models.speech_to_text

Bokeh Model of the Panel SpeechToText widget

class panel.models.speech_to_text.SpeechToText(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Widget

Bokeh Model of the Panel SpeechToText widget

Controls the speech recognition service.

On some browsers, like Chrome, using Speech Recognition on a web page involves a server-based recognition engine. Your audio is sent to a web service for recognition processing, so it won’t work offline.

Wraps the HTML5 SpeechRecognition API. See https://developer.mozilla.org/en-US/docs/Web/API/SpeechRecognition

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


state Module#

Inheritance diagram of panel.models.state
class panel.models.state.State(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Model

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

property document: Document | None#

The |Document| this model is attached to (can be None)

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
json#

Whether the values point to json files

classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

state#

Contains the recorded state

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)

tabs Module#

Inheritance diagram of panel.models.tabs
class panel.models.tabs.Tabs(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Tabs

Subclass of bokeh tabs with handling to ensure z-index correctness.

active#

The index of the active tab.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tabs#

The list of child panel widgets.

tabs_location#

The location of the buttons that activate tabs.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


tabulator Module#

Inheritance diagram of panel.models.tabulator

Implementation of the Tabulator model.

See http://tabulator.info/

class panel.models.tabulator.CellClickEvent(model, column, row, value=None)[source]#

Bases: ModelEvent

class panel.models.tabulator.DataTabulator(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLBox

A Bokeh Model that enables easy use of Tabulator tables See http://tabulator.info/

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

columns#

The list of child column widgets.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.tabulator.SelectionEvent(model, indices, selected, flush)[source]#

Bases: ModelEvent

class panel.models.tabulator.TableEditEvent(model, column, row, pre=False, value=None, old=None)[source]#

Bases: ModelEvent


terminal Module#

Inheritance diagram of panel.models.terminal
class panel.models.terminal.KeystrokeEvent(model, key=None)[source]#

Bases: ModelEvent

class panel.models.terminal.Terminal(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLBox

Custom Terminal Model

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


text_to_speech Module#

Inheritance diagram of panel.models.text_to_speech

The TextToSpeek Bokeh Model wraps the HTML5 SpeechSynthesis API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesisVoice

class panel.models.text_to_speech.TextToSpeech(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Widget

The TextToSpeek Bokeh Model wraps the HTML5 SpeechSynthesis API

See https://developer.mozilla.org/en-US/docs/Web/API/SpeechSynthesis

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


trend Module#

Inheritance diagram of panel.models.trend

A Bokeh model indicating trends.

class panel.models.trend.TrendIndicator(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLBox

A Bokeh model indicating trends.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


vega Module#

Inheritance diagram of panel.models.vega

Defines custom VegaPlot bokeh model to render Vega json plots.

class panel.models.vega.VegaEvent(model, data=None)[source]#

Bases: ModelEvent

class panel.models.vega.VegaPlot(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: LayoutDOM

A Bokeh model that wraps around a Vega plot and renders it inside a Bokeh plot.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


vizzu Module#

Inheritance diagram of panel.models.vizzu

Defines custom VizzuChart bokeh model to render Vizzu charts.

class panel.models.vizzu.VizzuChart(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: LayoutDOM

A Bokeh model that wraps around a Vizzu chart and renders it inside a Bokeh.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

source#

Local data source to use when rendering glyphs on the plot.

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.vizzu.VizzuEvent(model, data=None)[source]#

Bases: ModelEvent


vtk Module#

Inheritance diagram of panel.models.vtk

Defines custom VTKPlot bokeh model to render VTK objects.

class panel.models.vtk.AbstractVTKPlot(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: HTMLBox

Abstract Bokeh model for vtk plots that wraps around a vtk-js library and renders it inside a Bokeh plot.

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#

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.vtk.VTKAxes(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Model

A Bokeh model for axes

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

property document: Document | None#

The |Document| this model is attached to (can be None)

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
class panel.models.vtk.VTKJSPlot(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: AbstractVTKPlot

Bokeh model for plotting a 3D scene saved in the .vtk-js format

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

data#

The serialized vtk.js data

data_url#

The data URL

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.vtk.VTKSynchronizedPlot(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: AbstractVTKPlot

Bokeh model for plotting a VTK render window

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

rebuild#

If true when scene change all the render is rebuilt from scratch

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

scene#

The serialized vtk.js scene on json format

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.vtk.VTKVolumePlot(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: AbstractVTKPlot

Bokeh model dedicated to plot a volumetric object with the help of vtk-js

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

colormap#

Colormap Name

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

controller_expanded#

If True the volume controller panel options is expanded in the view

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.


widgets Module#

Inheritance diagram of panel.models.widgets

Custom bokeh Widget models.

class panel.models.widgets.Button(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Button

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

button_type#

A style for the button, signifying it’s role. Possible values are one of the following:

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

icon#

An optional image appearing to the left of button’s text. An instance of Icon (such as BuiltinIcon, SVGIcon, or TablerIcon).`

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_on_click(handler: Callback) None[source]#

Set up a JavaScript handler for button clicks.

js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
label#

Either HTML or plain text label for the button to display.

classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_click(handler: EventCallback) None[source]#

Set up a handler for button clicks.

Parameters:

handler (func) – handler function to call when button is clicked.

Returns:

None

on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

tooltip#

A tooltip with plain text or rich HTML contents, providing general help or description of a widget’s or component’s function.

tooltip_delay#

Delay (in milliseconds) to display the tooltip after the cursor has hovered over the Button, default is 500ms.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.widgets.CheckboxButtonGroup(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: CheckboxButtonGroup

active#

The list of indices of selected check boxes.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

button_type#

A style for the button, signifying it’s role. Possible values are one of the following:

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
labels#

List of text labels contained in this group.

classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

orientation#

Orient the button group either horizontally (default) or vertically.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

tooltip#

A tooltip with plain text or rich HTML contents, providing general help or description of a widget’s or component’s function.

tooltip_delay#

Delay (in milliseconds) to display the tooltip after the cursor has hovered over the Button, default is 500ms.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.widgets.CustomSelect(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Select

Custom widget that extends the base Bokeh Select by adding a parameter to disable one or more options.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

description#

Either a plain text or a tooltip with a rich HTML description of the function of this widget.

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

disabled_options#

List of options to disable.

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

options#

Available selection options.

Options may be provided either as a list of possible string values, which also act as options’ labels, or as a list of tuples, each of the form (value, label), where value can be of any type, not necessarily a string. In the latter case, the visible widget text for each value will be corresponding given label.

Option groupings can be provided by supplying a dictionary object whose values are in the aforementioned list format.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

title#

Widget’s label.

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
value#

Initial or selected value.

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.widgets.FileDownload(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: InputWidget

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

auto#

Whether to download on click

button_type#

A style for the button, signifying it’s role.

clicks#

A private property that used to trigger on_click event handler.

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

data#

Encoded URI data.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

description#

Either a plain text or a tooltip with a rich HTML description of the function of this widget.

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

embed#

Whether the data is pre-embedded.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

filename#

Filename to use on download

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

icon#

An optional image appearing to the left of button’s text. An instance of Icon (such as BuiltinIcon, SVGIcon, or TablerIcon).`

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
label#

The text label for the button to display.

classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

title#

Widget’s label.

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.widgets.Player(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Widget

The Player widget provides controls to play through a number of frames.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

direction#

playing in reverse, 0: paused, 1: playing)

Type:

Current play direction of the Player (-1

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

end#

Upper bound of the Player slider

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

interval#

Interval between updates

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

show_loop_controls#

Whether the loop controls radio buttons are shown

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

start#

Lower bound of the Player slider

step#

Number of steps to advance the player by.

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
value#

Current value of the player app

value_throttled#

Current throttled value of the player app

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.widgets.RadioButtonGroup(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: RadioButtonGroup

active#

The index of the selected radio box, or None if nothing is selected.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

button_type#

A style for the button, signifying it’s role. Possible values are one of the following:

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
labels#

List of text labels contained in this group.

classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

orientation#

Orient the button group either horizontally (default) or vertically.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

tooltip#

A tooltip with plain text or rich HTML contents, providing general help or description of a widget’s or component’s function.

tooltip_delay#

Delay (in milliseconds) to display the tooltip after the cursor has hovered over the Button, default is 500ms.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.widgets.SingleSelect(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: InputWidget

Single-select widget.

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

description#

Either a plain text or a tooltip with a rich HTML description of the function of this widget.

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

disabled_options#

List of options to disable.

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

options#

Available selection options. Options may be provided either as a list of possible string values, or as a list of tuples, each of the form (value, label). In the latter case, the visible widget text for each value will be corresponding given label.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

size#

The number of visible options in the dropdown list. (This uses the select HTML element’s size attribute. Some browsers might not show less than 3 options.)

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

title#

Widget’s label.

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
value#

Initial or selected value.

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.widgets.TextAreaInput(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: TextAreaInput

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

auto_grow#

Whether the text area should automatically grow vertically to accommodate the current text.

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

cols#

20

Type:

Specifies the width of the text area (in average character width). Default

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

description#

Either a plain text or a tooltip with a rich HTML description of the function of this widget.

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_length#

Max count of characters in field

max_rows#

Maximum number of rows the input area can grow to if auto_grow is enabled.

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

placeholder#

Placeholder for empty input field.

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

rows#

2

Type:

Specifies the height of the text area (in lines). Default

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

title#

Widget’s label.

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
value#

Initial or entered text value.

Change events are triggered whenever <enter> is pressed.

value_input#

Initial or current value.

Change events are triggered whenever any update happens, i.e. on every keypress.

visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.

class panel.models.widgets.TooltipIcon(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Widget

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

apply_theme(property_values: dict[str, Any]) None[source]#

Apply a set of theme values which will be used rather than defaults, but will not override application-set values.

The passed-in dictionary may be kept around as-is and shared with other instances to save memory (so neither the caller nor the |HasProps| instance should modify it).

Parameters:

property_values (dict) – theme values to use in place of defaults

Returns:

None

aspect_ratio#

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

clone(**overrides: Any) Self[source]#

Duplicate a HasProps object.

This creates a shallow clone of the original model, i.e. any mutable containers or child models will not be duplicated. Allows to override particular properties while cloning.

context_menu#

A menu to display when user right clicks on the component.

Note

Use shift key when right clicking to display the native context menu.

css_classes#

A list of additional CSS classes to add to the underlying DOM element.

css_variables#

Allows to define dynamically computed CSS variables.

This can be used, for example, to coordinate positioning and styling between canvas’ renderers and/or visuals and HTML-based UI elements.

Variables defined here are equivalent to setting the same variables under :host { ... } in a CSS stylesheet.

Note

This property is experimental and may change at any point.

classmethod dataspecs() dict[str, DataSpec][source]#

Collect the names of all DataSpec properties on this class.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of DataSpec properties

Return type:

set[str]

description#

The tooltip held by the icon

classmethod descriptors() list[bokeh.core.property.descriptors.PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

disabled#

Whether the widget will be disabled when rendered.

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

property document: Document | None#

The |Document| this model is attached to (can be None)

elements#

A collection of DOM-based UI elements attached to this pane.

This can include floating elements like tooltips, allowing to establish a parent-child relationship between this and other UI elements.

equals(other: HasProps) bool[source]#

Structural equality of models.

Parameters:

other (HasProps) – the other instance to compare to

Returns:

True, if properties are structurally equal, otherwise False

flow_mode#

Defines whether the layout will flow in the block or inline dimension.

height: int | None#

The height of the component (in pixels).

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

height_policy#

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

js_event_callbacks#

A mapping of event names to lists of CustomJS callbacks.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_event method:

callback = CustomJS(code="console.log('tap event occurred')")
plot.js_on_event('tap', callback)

Link two Bokeh model properties using JavaScript.

This is a convenience method that simplifies adding a CustomJS callback to update one Bokeh model property whenever another changes value.

Parameters:
  • attr (str) – The name of a Bokeh property on this model

  • other (Model) – A Bokeh model to link to self.attr

  • other_attr (str) – The property on other to link together

  • attr_selector (Union[int, str]) – The index to link an item in a subscriptable attr

Added in version 1.1

Raises:

ValueError

Examples

This code with js_link:

select.js_link('value', plot, 'sizing_mode')

is equivalent to the following:

from bokeh.models import CustomJS
select.js_on_change('value',
    CustomJS(args=dict(other=plot),
             code="other.sizing_mode = this.value"
    )
)

Additionally, to use attr_selector to attach the left side of a range slider to a plot’s x_range:

range_slider.js_link('value', plot.x_range, 'start', attr_selector=0)

which is equivalent to:

from bokeh.models import CustomJS
range_slider.js_on_change('value',
    CustomJS(args=dict(other=plot.x_range),
             code="other.start = this.value[0]"
    )
)
js_on_change(event: str, *callbacks: JSChangeCallback) None[source]#

Attach a CustomJS callback to an arbitrary BokehJS model event.

On the BokehJS side, change events for model properties have the form "change:property_name". As a convenience, if the event name passed to this method is also the name of a property on the model, then it will be prefixed with "change:" automatically:

# these two are equivalent
source.js_on_change('data', callback)
source.js_on_change('change:data', callback)

However, there are other kinds of events that can be useful to respond to, in addition to property change events. For example to run a callback whenever data is streamed to a ColumnDataSource, use the "stream" event on the source:

source.js_on_change('streaming', callback)
js_property_callbacks#

A mapping of attribute names to lists of CustomJS callbacks, to be set up on BokehJS side when the document is created.

Typically, rather then modifying this property directly, callbacks should be added using the Model.js_on_change method:

callback = CustomJS(code="console.log('stuff')")
plot.x_range.js_on_change('start', callback)
classmethod lookup(name: str, *, raises: bool = True) Optional[PropertyDescriptor[Any]][source]#

Find the PropertyDescriptor for a Bokeh property on a class, given the property name.

Parameters:
  • name (str) – name of the property to search for

  • raises (bool) – whether to raise or return None if missing

Returns:

descriptor for property named name

Return type:

PropertyDescriptor

margin#

Allows to create additional space around the component. The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left, similar to CSS standards. Negative margin values may be used to shrink the space from any direction.

max_height#

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

max_width#

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

min_height#

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

min_width#

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

name: str | None#

An arbitrary, user-supplied name for this model.

This name can be useful when querying the document to retrieve specific Bokeh models.

>>> plot.circle([1,2,3], [4,5,6], name="temp")
>>> plot.select(name="temp")
[GlyphRenderer(id='399d53f5-73e9-44d9-9527-544b761c7705', ...)]

Note

No uniqueness guarantees or other conditions are enforced on any names that are provided, nor is the name used directly by Bokeh for any reason.

on_change(attr: str, *callbacks: PropertyCallback) None[source]#

Add a callback on this object to trigger when attr changes.

Parameters:
  • attr (str) – an attribute name on this object

  • *callbacks (callable) – callback functions to register

Returns:

None

Examples

widget.on_change('value', callback1, callback2, ..., callback_n)
on_event(event: str | type[bokeh.events.Event], *callbacks: Union[Callable[[Event], None], Callable[[], None]]) None[source]#

Run callbacks when the specified event occurs on this Model

Not all Events are supported for all Models. See specific Events in bokeh.events for more information on which Models are able to trigger them.

classmethod parameters() list[inspect.Parameter][source]#

Generate Python Parameter values suitable for functions that are derived from the glyph.

Returns:

list(Parameter)

classmethod properties(*, _with_props: bool = False) set[str] | dict[str, Property[Any]][source]#

Collect the names of properties on this class.

Warning

In a future version of Bokeh, this method will return a dictionary mapping property names to property objects. To future-proof this current usage of this method, wrap the return value in list.

Returns:

property names

classmethod properties_with_refs() dict[str, Property[Any]][source]#

Collect the names of all properties on this class that also have references.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Returns:

names of properties that have references

Return type:

set[str]

properties_with_values(*, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Collect a dict mapping property names to their values.

This method always traverses the class hierarchy and includes properties defined on any parent classes.

Non-serializable properties are skipped and property values are in “serialized” format which may be slightly different from the values you would normally read from the properties; the intent of this method is to return the information needed to losslessly reconstitute the object instance.

Parameters:

include_defaults (bool, optional) – Whether to include properties that haven’t been explicitly set since the object was created. (default: True)

Returns:

mapping from property names to their values

Return type:

dict

query_properties_with_values(query: Callable[[PropertyDescriptor[Any]], bool], *, include_defaults: bool = True, include_undefined: bool = False) dict[str, Any][source]#

Query the properties values of |HasProps| instances with a predicate.

Parameters:
  • query (callable) – A callable that accepts property descriptors and returns True or False

  • include_defaults (bool, optional) – Whether to include properties that have not been explicitly set by a user (default: True)

Returns:

mapping of property names and values for matching properties

Return type:

dict

references() set[bokeh.model.model.Model][source]#

Returns all Models that this object has references to.

remove_on_change(attr: str, *callbacks: Callable[[str, Any, Any], None]) None[source]#

Remove a callback from this object

resizable#

Whether the layout is interactively resizable, and if so in which dimensions.

select(selector: SelectorType) Iterable[Model][source]#

Query this object and all of its references for objects that match the given selector.

Parameters:

selector (JSON-like) –

Returns:

seq[Model]

select_one(selector: SelectorType) Model | None[source]#

Query this object and all of its references for objects that match the given selector. Raises an error if more than one object is found. Returns single matching object, or None if nothing is found :param selector: :type selector: JSON-like

Returns:

Model

set_from_json(name: str, value: Any, *, setter: Setter | None = None) None[source]#

Set a property value on this object from JSON.

Parameters:
  • name – (str) : name of the attribute to set

  • json – (JSON-value) : value to set to the attribute to

  • models (dict or None, optional) –

    Mapping of model ids to models (default: None)

    This is needed in cases where the attributes to update also have values that have references.

  • setter (ClientSession or ServerSession or None, optional) –

    This is used to prevent “boomerang” updates to Bokeh apps.

    In the context of a Bokeh server application, incoming updates to properties will be annotated with the session that is doing the updating. This value is propagated through any subsequent change notifications that the update triggers. The session can compare the event setter to itself, and suppress any updates that originate from itself.

Returns:

None

set_select(selector: type[Model] | SelectorType, updates: dict[str, Any]) None[source]#

Update objects that match a given selector with the specified attribute/value updates.

Parameters:
  • selector (JSON-like) –

  • updates (dict) –

Returns:

None

sizing_mode#

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:

"inherit"

The sizing mode is inherited from the parent layout. If there is no parent layout (or parent is not a layout), then this value is treated as if no value for sizing_mode was provided.

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

styles#

Inline CSS styles applied to the underlying DOM element.

stylesheets#

Additional style-sheets to use for the underlying DOM element.

Note that all bokeh’s components use shadow DOM, thus any included style sheets must reflect that, e.g. use :host CSS pseudo selector to access the root DOM element.

subscribed_events: set[str]#

Collection of events that are subscribed to by Python callbacks. This is the set of events that will be communicated from BokehJS back to Python for this model.

syncable: bool#

Indicates whether this model should be synchronized back to a Bokeh server when updated in a web browser. Setting to False may be useful to reduce network traffic when dealing with frequently updated objects whose updated values we don’t need.

Note

Setting this property to False will prevent any on_change() callbacks on this object from triggering. However, any JS-side callbacks will still work.

tags: list[Any]#

An optional list of arbitrary, user-supplied values to attach to this model.

This data can be useful when querying the document to retrieve specific Bokeh models:

>>> r = plot.circle([1,2,3], [4,5,6])
>>> r.tags = ["foo", 10]
>>> plot.select(tags=['foo', 10])
[GlyphRenderer(id='1de4c3df-a83d-480a-899b-fb263d3d5dd9', ...)]

Or simply a convenient way to attach any necessary metadata to a model that can be accessed by CustomJS callbacks, etc.

Note

No uniqueness guarantees or other conditions are enforced on any tags that are provided, nor are the tags used directly by Bokeh for any reason.

themed_values() dict[str, Any] | None[source]#

Get any theme-provided overrides.

Results are returned as a dict from property name to value, or None if no theme overrides any values for this instance.

Returns:

dict or None

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

trigger(attr: str, old: Any, new: Any, hint: DocumentPatchedEvent | None = None, setter: Setter | None = None) None[source]#
unapply_theme() None[source]#

Remove any themed values and restore defaults.

Returns:

None

update(**kwargs: Any) None[source]#

Updates the object’s properties from the given keyword arguments.

Returns:

None

Examples

The following are equivalent:

from bokeh.models import Range1d

r = Range1d

# set properties individually:
r.start = 10
r.end = 20

# update properties together:
r.update(start=10, end=20)
visible#

Whether the component should be displayed on screen.

width: int | None#

The width of the component (in pixels).

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

width_policy#

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.