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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

Returns:

None

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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.

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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#

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

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:

set[str] : names of DataSpec properties

description#

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

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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#

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

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

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

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.


comm_manager Module#

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

Args:

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

Returns:

None

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

description#

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

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.


datetime_slider Module#

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

Bases: DateSlider

Slider-based datetime selection 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).

Args:

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

bar_color#

Acceptable values are:

  • any of the |named CSS colors|, e.g 'green', 'indigo'

  • RGB(A) hex strings, e.g., '#FF0000', '#44444444'

  • CSS4 color strings, e.g., 'rgba(255, 0, 127, 0.6)', 'rgb(0 127 0 / 1.0)', or 'hsl(60deg 100% 50% / 1.0)'

  • a 3-tuple of integers (r, g, b) between 0 and 255

  • a 4-tuple of (r, g, b, a) where r, g, b are integers between 0 and 255, and a is between 0 and 1

  • a 32-bit unsigned integer using the 0xRRGGBBAA byte order pattern

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

direction#
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#

The maximum allowable value.

equals(other: HasProps) bool[source]#

Structural equality of models.

Args:

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.

format#
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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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 slider either horizontally (default) or vertically.

classmethod parameters() list[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

selector (JSON-like) : updates (dict) :

Returns:

None

show_value#

Whether or not show slider’s value.

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#

The minimum allowable value.

step#

The step between consecutive values, in units of days.

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 slider’s label (supports math text).

to_serializable(serializer: Serializer) ObjectRefRep[source]#

Converts this object to a serializable representation.

tooltips#

Display the slider’s current value in a tooltip.

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.

property value_as_date: date | None#

Convenience property to retrieve the value as a date object.

Added in version 2.0

property value_as_datetime: datetime | None#

Convenience property to retrieve the value as a datetime object.

Added in version 2.0

value_throttled#

Initial or selected value, throttled to report only on mouseup.

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.


enums Module#

Declares enumerations for various model properties.


esm Module#

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

Bases: ReactComponent

Renders AnyWidget esm definitions by adding a compatibility layer.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.esm.DataEvent(model, data=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

class panel.models.esm.ESMEvent(model, data=None)[source]#

Bases: DataEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

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

Bases: ReactiveESM

Renders jsx/tsx based ESM bundles using React.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.


feed Module#

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

Args:

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.

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

class panel.models.feed.ScrollLatestEvent(model, rerender=False)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.


file_dropper Module#

class panel.models.file_dropper.DeleteEvent(model, data=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

class panel.models.file_dropper.FileDropper(*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).

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

description#

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

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.file_dropper.UploadEvent(model, data=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.


icon Module#

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

Args:

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:

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#


jsoneditor Module#

Custom bokeh Markup models.

class panel.models.jsoneditor.JSONEditEvent(model, data=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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.

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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.

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

Returns:

None

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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#

The full url, e.g. ‘https://localhost:80?color=blue#interact

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.HTMLStreamEvent(model, patch=None, start=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

depth#

Depth to which the JSON tree is expanded.

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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: Div

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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

render_as_text#

Whether the contents should be rendered as raw text or as interpreted HTML. The default value is False, meaning contents are rendered as HTML.

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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

class panel.models.perspective.PerspectiveClickEvent(model, config, column_names, row)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.


plotly Module#

Defines a custom PlotlyPlot bokeh model to render Plotly plots.

class panel.models.plotly.PlotlyEvent(model, data=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

class panel.models.reactive_html.DOMEvent(model, node=None, data=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

Returns:

None

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

Implementation of the Tabulator model.

See http://tabulator.info/

class panel.models.tabulator.CellClickEvent(model, column, row, value=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

class panel.models.tabulator.TableEditEvent(model, column, row, pre=False, value=None, old=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.


terminal Module#

class panel.models.terminal.KeystrokeEvent(model, key=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.


time_picker Module#

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

Bases: TimePicker

A custom Panel version of the Bokeh TimePicker model which fixes timezones.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

clock#

Whether to use 12 hour or 24 hour clock.

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:

set[str] : names of DataSpec properties

description#

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

classmethod descriptors() list[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.

Args:

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.

hour_increment#

Defines the granularity of hour value incremements in the UI.

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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_time#

Optional latest allowable time.

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_time#

Optional earliest allowable time.

min_width#

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

minute_increment#

Defines the granularity of minute value incremements in the UI.

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

second_increment#

Defines the granularity of second value incremements in the UI.

seconds#

Allows to select seconds. By default only hours and minuts are selectable, and AM/PM depending on clock option.

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

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

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

time_format#

Formatting specification for the display of the picked date.

H h G i S s K

Hours (24 hours) Hours Hours, 2 digits with leading zeros Minutes Seconds, 2 digits Seconds AM/PM

00 to 23 1 to 12 1 to 12 00 to 59 00 to 59 0, 1 to 59 AM or PM

See also https://flatpickr.js.org/formatting/#date-formatting-tokens.

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

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

Defines custom VegaPlot bokeh model to render Vega json plots.

class panel.models.vega.VegaEvent(model, data=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.


vtk Module#

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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

Returns:

None

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

rebuild#

If true when scene change all the render is rebuilt from scratch

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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#

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

Args:

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:

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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.

Args:

handler (func) : handler function to call when button is clicked.

Returns:

None

on_event(event: str | type[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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:

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.CustomMultiSelect(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: MultiSelect

MultiSelect widget which allows capturing double tap events.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

description#

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

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

description#

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

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.DiscretePlayer(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: Player

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

direction#

Current play direction of the Player (-1: playing in reverse, 0: paused, 1: playing)

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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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#

List of discrete options.

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

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

Returns:

list(Parameter)

preview_duration#

Duration (in milliseconds) for showing the current FPS when clicking the slower/faster buttons, before reverting to the icon.

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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

scale_buttons#

Percentage to scale the size of the buttons by

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

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

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

selector (JSON-like) : updates (dict) :

Returns:

None

show_loop_controls#

Whether the loop controls radio buttons are shown

show_value#

Whether to show the widget value

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

title#

The slider’s label (supports math text).

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_align#

Location to display the value of the slider (“start” “center”, “end”)

value_throttled#

Current throttled value of the player app

visible#

Whether the component should be displayed on screen.

visible_buttons#

The buttons to display on the player.

visible_loop_options#

The loop options to display on the player.

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.DoubleClickEvent(model, option=None)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

class panel.models.widgets.EnterEvent(model, value_input)[source]#

Bases: ModelEvent

to_serializable(serializer: Serializer) BokehEventRep[source]#

Converts this object to a serializable representation.

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

Args:

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.

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

description#

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

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[PropertyDescriptor[Any]][source]#

List of property descriptors in the order of definition.

destroy() None[source]#

Clean up references to the document and property

direction#

Current play direction of the Player (-1: playing in reverse, 0: paused, 1: playing)

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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[Parameter][source]#

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

Returns:

list(Parameter)

preview_duration#

Duration (in milliseconds) for showing the current FPS when clicking the slower/faster buttons, before reverting to the icon.

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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

scale_buttons#

Percentage to scale the size of the buttons by

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

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

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

selector (JSON-like) : updates (dict) :

Returns:

None

show_loop_controls#

Whether the loop controls radio buttons are shown

show_value#

Whether to show the widget value

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

title#

The slider’s label (supports math text).

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_align#

Location to display the value of the slider (“start” “center”, “end”)

value_throttled#

Current throttled value of the player app

visible#

Whether the component should be displayed on screen.

visible_buttons#

The buttons to display on the player.

visible_loop_options#

The loop options to display on the player.

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

Args:

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:

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

description#

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

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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

Args:

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.

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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#

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

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:

set[str] : names of DataSpec properties

description#

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

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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#

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

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

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

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.TextInput(*args: Any, id: ID | None = None, **kwargs: Any)[source]#

Bases: TextInput

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

description#

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

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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

Args:

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[Event], *callbacks: 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[Parameter][source]#

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

Returns:

list(Parameter)

placeholder#

Placeholder for empty input field.

prefix#

An optional string prefix to display before the input. This is useful to indicate e.g. a variable the entered value will be assigned to.

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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.

suffix#

An optional string suffix to display after the input. This is useful to indicate e.g. the units of measurement of the entered value.

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

Args:

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

classmethod clear_extensions() None[source]#

Clear any currently defined custom extensions.

Serialization calls will result in any currently defined custom extensions being included with the generated Document, whether or not there are utlized. This method can be used to clear out all existing custom extension definitions.

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:

set[str] : names of DataSpec properties

description#

The tooltip held by the icon

classmethod descriptors() list[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.

Args:

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.

Args:

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 (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) PropertyDescriptor[Any] | None[source]#

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

Args:

name (str) : name of the property to search for raises (bool) : whether to raise or return None if missing

Returns:

PropertyDescriptor : descriptor for property named name

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.

Args:

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[Event], *callbacks: 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[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:

set[str] : names of properties that have references

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.

Args:
include_defaults (bool, optional) :

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

Returns:

dict : mapping from property names to their values

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.

Args:
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:

dict : mapping of property names and values for matching properties

references() set[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.

Args:

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 Args:

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.

Args:

name (str) : name of the attribute to set

value (JSON-value) : value to set to the attribute to

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.

Args:

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.