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.


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