panel.vtk Package#


vtk Package#


enums Module#

class panel.pane.vtk.enums.TextPosition(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum


synchronizable_deserializer Module#


synchronizable_serializer Module#


vtk Module#

Defines a VTKPane which renders a vtk plot using VTKPlot bokeh model.

class panel.pane.vtk.vtk.AbstractVTK(object=None, **params)[source]#

Bases: Pane

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

axes = param.Dict(allow_refs=False, class_=<class ‘dict’>, default={}, label=’Axes’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x164561b10>)

Parameters of the axes to construct in the 3d view. Must contain at least xticker, yticker and zticker. A ticker is a dictionary which contains: - ticks (array of numbers) - required. Positions in the scene coordinates of the corresponding axis’ ticks. - labels (array of strings) - optional. Label displayed respectively to the ticks positions. If labels are not defined they are inferred from the ticks array. - digits: number of decimal digits when ticks are converted to labels. - fontsize: size in pts of the ticks labels. - show_grid: boolean. If true (default) the axes grid is visible. - grid_opacity: float between 0-1. Defines the grid opacity. - axes_opacity: float between 0-1. Defines the axes lines opacity.

camera = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Camera’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x16484df10>)

State of the rendered VTK camera.

color_mappers = param.List(allow_refs=False, bounds=(0, None), default=[], label=’Color mappers’, nested_refs=True, rx=<param.reactive.reactive_ops object at 0x164614050>)

Color mapper of the actor in the scene

orientation_widget = param.Boolean(allow_refs=False, default=False, label=’Orientation widget’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x164702e50>)

Activate/Deactivate the orientation widget display.

interactive_orientation_widget = param.Boolean(allow_refs=False, constant=True, default=True, label=’Interactive orientation widget’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1647f6b50>)

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

links: dict

Maps between parameters on this object to the parameters on the supplied object.

save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | Template | None = None, template_variables: dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector: type | Callable[[Viewable], bool] | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.vtk.vtk.BaseVTKRenderWindow(object, **params)[source]#

Bases: AbstractVTK

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.vtk.vtk.AbstractVTK: axes, camera, color_mappers, orientation_widget, interactive_orientation_widget

enable_keybindings = param.Boolean(allow_refs=False, default=False, label=’Enable keybindings’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1625d5990>)

Activate/Deactivate keys binding. Warning: These keys bind may not work as expected in a notebook context if they interact with already binded keys

serialize_on_instantiation = param.Boolean(allow_refs=False, constant=True, default=False, label=’Serialize on instantiation’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x164898050>)

defines when the serialization of the vtkRenderWindow scene occurs. If set to True the scene object is serialized when the pane is created else (default) when the panel is displayed to the screen. This parameter is constant, once set it can’t be modified. Warning: when the serialization occurs at instantiation, the vtkRenderWindow and the view are not fully synchronized. The view displays the state of the scene captured when the panel was created, if elements where added or removed between the instantiation and the display these changes will not be reflected. Moreover when the pane object is updated (replaced or call to param.trigger(‘object’)), all the scene is rebuilt from scratch.

serialize_all_data_arrays = param.Boolean(allow_refs=False, constant=True, default=False, label=’Serialize all data arrays’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1625d5990>)

If true, enable the serialization of all data arrays of vtkDataSets (point data, cell data and field data). By default the value is False and only active scalars of each dataset are serialized and transfer to the javascript side. Enabling this option will increase memory and network transfer volume but results in more reactive visualizations by using some custom javascript functions.

classmethod applies(obj, **kwargs)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_renderer()[source]#

Get the vtk Renderer associated to this pane

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

links: dict

Maps between parameters on this object to the parameters on the supplied object.

save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | Template | None = None, template_variables: dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector: type | Callable[[Viewable], bool] | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.vtk.vtk.SyncHelpers[source]#

Bases: object

Class containing helpers functions to update vtkRenderingWindow

add_actors(actors)[source]#

Add a list of actors to the VTK renderer if reset_camera is True, the current camera and it’s clipping will be reset.

remove_actors(actors)[source]#

Add a list of actors to the VTK renderer if reset_camera is True, the current camera and it’s clipping will be reset.

abstract reset_camera()[source]#

Reset the camera

abstract synchronize()[source]#

function to synchronize the renderer with the view

class panel.pane.vtk.vtk.VTK(obj, **params)[source]#

Bases: object

The VTK pane renders a VTK scene inside a panel, making it possible to interact with complex geometries in 3D.

Reference: https://panel.holoviz.org/reference/panes/VTK.html

Example:

>>> pn.extension('vtk')
>>> VTK(some_vtk_object, width=500, height=500)

This is a Class factory and allows to switch between VTKJS, VTKRenderWindow, and VTKRenderWindowSynchronized pane as a function of the object type and when the serialisation of the vtkRenderWindow occurs.

Once a pane is returned by this class (inst = VTK(object)), one can use pn.help(inst) to see parameters available for the current pane

class panel.pane.vtk.vtk.VTKJS(object=None, **params)[source]#

Bases: AbstractVTK

The VTKJS pane allow rendering a vtk scene stored in a vtkjs.

Reference: https://panel.holoviz.org/reference/panes/VTKJS.html

Example:

>>> pn.extension('vtk')
>>> VTK(
...    'https://raw.githubusercontent.com/Kitware/vtk-js/master/Data/StanfordDragon.vtkjs',
...     sizing_mode='stretch_width', height=400, enable_keybindings=True,
...     orientation_widget=True
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.vtk.vtk.AbstractVTK: axes, camera, color_mappers, orientation_widget, interactive_orientation_widget

enable_keybindings = param.Boolean(allow_refs=False, default=False, label=’Enable keybindings’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x164962850>)

Activate/Deactivate keys binding. Warning: These keybindings may not work as expected in a notebook context if they interact with already bound keys.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

export_vtkjs(filename: str | IO = 'vtk_panel.vtkjs')[source]#

Exports current VTK data to .vtkjs file.

Arguments#

filename: str | IO

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

links: dict

Maps between parameters on this object to the parameters on the supplied object.

save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | Template | None = None, template_variables: dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector: type | Callable[[Viewable], bool] | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.vtk.vtk.VTKRenderWindow(object=None, **params)[source]#

Bases: BaseVTKRenderWindow

VTK panes allow rendering vtkRenderWindow objects. Capture the scene of the vtkRenderWindow passed at instantiation To update the display a new vtkRenderWindow must be passed as object

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.vtk.vtk.AbstractVTK: axes, camera, color_mappers, orientation_widget, interactive_orientation_widget

panel.pane.vtk.vtk.BaseVTKRenderWindow: enable_keybindings, serialize_on_instantiation, serialize_all_data_arrays

classmethod applies(obj, **kwargs)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_renderer()[source]#

Get the vtk Renderer associated to this pane

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

links: dict

Maps between parameters on this object to the parameters on the supplied object.

save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | Template | None = None, template_variables: dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector: type | Callable[[Viewable], bool] | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

class panel.pane.vtk.vtk.VTKRenderWindowSynchronized(object=None, **params)[source]#

Bases: BaseVTKRenderWindow, SyncHelpers

VTK panes allow rendering VTK objects. Synchronize a vtkRenderWindow constructs on python side with a custom bokeh model on javascript side

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.vtk.vtk.AbstractVTK: axes, camera, color_mappers, orientation_widget

panel.pane.vtk.vtk.BaseVTKRenderWindow: enable_keybindings, serialize_on_instantiation, serialize_all_data_arrays

interactive_orientation_widget = param.Boolean(allow_refs=False, constant=True, default=False, label=’Interactive orientation widget’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16499a290>)

_one_time_reset = param.Boolean(allow_refs=False, default=False, label=’ one time reset’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x164999a50>)

add_actors(actors)[source]#

Add a list of actors to the VTK renderer if reset_camera is True, the current camera and it’s clipping will be reset.

classmethod applies(obj, **kwargs)[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_renderer()[source]#

Get the vtk Renderer associated to this pane

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

links: dict

Maps between parameters on this object to the parameters on the supplied object.

Associate the camera of an other VTKSynchronized pane to this renderer

remove_actors(actors)[source]#

Add a list of actors to the VTK renderer if reset_camera is True, the current camera and it’s clipping will be reset.

reset_camera()[source]#

Reset the camera

save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | Template | None = None, template_variables: dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector: type | Callable[[Viewable], bool] | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)

synchronize()[source]#

function to synchronize the renderer with the view

Create a fresh vtkCamera instance and set it to the renderer

class panel.pane.vtk.vtk.VTKVolume(object=None, **params)[source]#

Bases: AbstractVTK

The VTKVolume pane renders 3d volumetric data defined on regular grids. It may be constructed from a 3D NumPy array or a vtkVolume.

The pane provides a number of interactive control which can be set either through callbacks from Python or Javascript callbacks.

Reference: https://panel.holoviz.org/reference/panes/VTKVolume.html

Example:

>>> pn.extension('vtk')
>>> VTKVolume(
...    data_matrix, spacing=(3,2,1), interpolation='nearest',
...    edge_gradient=0, sampling=0,
...    sizing_mode='stretch_width', height=400,
... )

Parameters inherited from:

panel.viewable.Layoutable: align, aspect_ratio, css_classes, design, height, min_width, min_height, max_width, max_height, styles, stylesheets, tags, width, width_policy, height_policy, sizing_mode, visible

panel.viewable.Viewable: loading

panel.pane.base.PaneBase: margin, default_layout, object

panel.pane.vtk.vtk.AbstractVTK: axes, camera, color_mappers, orientation_widget, interactive_orientation_widget

ambient = param.Number(allow_refs=False, default=0.2, inclusive_bounds=(True, True), label=’Ambient’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1649d30d0>, step=0.01)

Value to control the ambient lighting. It is the light an object gives even in the absence of strong light. It is constant in all directions.

controller_expanded = param.Boolean(allow_refs=False, default=True, label=’Controller expanded’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x164afef10>)

If True the volume controller panel options is expanded in the view

colormap = param.Selector(allow_refs=False, default=’erdc_rainbow_bright’, label=’Colormap’, names={}, nested_refs=False, objects=[‘KAAMS’, ‘Cool to Warm’, ‘Cool to Warm (Extended)’, ‘Warm to Cool’, ‘Warm to Cool (Extended)’, ‘Rainbow Desaturated’, ‘Cold and Hot’, ‘Black-Body Radiation’, ‘X Ray’, ‘Grayscale’, ‘BkRd’, ‘BkGn’, ‘BkBu’, ‘BkMa’, ‘BkCy’, ‘Black, Blue and White’, ‘Black, Orange and White’, ‘Linear YGB 1211g’, ‘Linear Green (Gr4L)’, ‘Linear Blue (8_31f)’, ‘Blue to Red Rainbow’, ‘Red to Blue Rainbow’, ‘Rainbow Blended White’, ‘Rainbow Blended Grey’, ‘Rainbow Blended Black’, ‘Blue to Yellow’, ‘blot’, ‘CIELab Blue to Red’, ‘jet’, ‘rainbow’, ‘erdc_rainbow_bright’, ‘erdc_rainbow_dark’, ‘nic_CubicL’, ‘nic_CubicYF’, ‘gist_earth’, ‘2hot’, ‘erdc_red2yellow_BW’, ‘erdc_marine2gold_BW’, ‘erdc_blue2gold_BW’, ‘erdc_sapphire2gold_BW’, ‘erdc_red2purple_BW’, ‘erdc_purple2pink_BW’, ‘erdc_pbj_lin’, ‘erdc_blue2green_muted’, ‘erdc_blue2green_BW’, ‘GREEN-WHITE_LINEAR’, ‘erdc_green2yellow_BW’, ‘blue2cyan’, ‘erdc_blue2cyan_BW’, ‘erdc_blue_BW’, ‘BLUE-WHITE’, ‘erdc_purple_BW’, ‘erdc_magenta_BW’, ‘magenta’, ‘RED-PURPLE’, ‘erdc_red_BW’, ‘RED_TEMPERATURE’, ‘erdc_orange_BW’, ‘heated_object’, ‘erdc_gold_BW’, ‘erdc_brown_BW’, ‘copper_Matlab’, ‘pink_Matlab’, ‘bone_Matlab’, ‘gray_Matlab’, ‘Purples’, ‘Blues’, ‘Greens’, ‘PuBu’, ‘BuPu’, ‘BuGn’, ‘GnBu’, ‘GnBuPu’, ‘BuGnYl’, ‘PuRd’, ‘RdPu’, ‘Oranges’, ‘Reds’, ‘RdOr’, ‘BrOrYl’, ‘RdOrYl’, ‘CIELab_blue2red’, ‘blue2yellow’, ‘erdc_blue2gold’, ‘erdc_blue2yellow’, ‘erdc_cyan2orange’, ‘erdc_purple2green’, ‘erdc_purple2green_dark’, ‘coolwarm’, ‘BuRd’, ‘Spectral_lowBlue’, ‘GnRP’, ‘GYPi’, ‘GnYlRd’, ‘GBBr’, ‘PuOr’, ‘PRGn’, ‘PiYG’, ‘OrPu’, ‘BrBG’, ‘GyRd’, ‘erdc_divHi_purpleGreen’, ‘erdc_divHi_purpleGreen_dim’, ‘erdc_divLow_icePeach’, ‘erdc_divLow_purpleGreen’, ‘Haze_green’, ‘Haze_lime’, ‘Haze’, ‘Haze_cyan’, ‘nic_Edge’, ‘erdc_iceFire_H’, ‘erdc_iceFire_L’, ‘hsv’, ‘hue_L60’, ‘Spectrum’, ‘Warm’, ‘Cool’, ‘Blues’, ‘Wild Flower’, ‘Citrus’, ‘Brewer Diverging Purple-Orange (11)’, ‘Brewer Diverging Purple-Orange (10)’, ‘Brewer Diverging Purple-Orange (9)’, ‘Brewer Diverging Purple-Orange (8)’, ‘Brewer Diverging Purple-Orange (7)’, ‘Brewer Diverging Purple-Orange (6)’, ‘Brewer Diverging Purple-Orange (5)’, ‘Brewer Diverging Purple-Orange (4)’, ‘Brewer Diverging Purple-Orange (3)’, ‘Brewer Diverging Spectral (11)’, ‘Brewer Diverging Spectral (10)’, ‘Brewer Diverging Spectral (9)’, ‘Brewer Diverging Spectral (8)’, ‘Brewer Diverging Spectral (7)’, ‘Brewer Diverging Spectral (6)’, ‘Brewer Diverging Spectral (5)’, ‘Brewer Diverging Spectral (4)’, ‘Brewer Diverging Spectral (3)’, ‘Brewer Diverging Brown-Blue-Green (11)’, ‘Brewer Diverging Brown-Blue-Green (10)’, ‘Brewer Diverging Brown-Blue-Green (9)’, ‘Brewer Diverging Brown-Blue-Green (8)’, ‘Brewer Diverging Brown-Blue-Green (7)’, ‘Brewer Diverging Brown-Blue-Green (6)’, ‘Brewer Diverging Brown-Blue-Green (5)’, ‘Brewer Diverging Brown-Blue-Green (4)’, ‘Brewer Diverging Brown-Blue-Green (3)’, ‘Brewer Sequential Blue-Green (9)’, ‘Brewer Sequential Blue-Green (8)’, ‘Brewer Sequential Blue-Green (7)’, ‘Brewer Sequential Blue-Green (6)’, ‘Brewer Sequential Blue-Green (5)’, ‘Brewer Sequential Blue-Green (4)’, ‘Brewer Sequential Blue-Green (3)’, ‘Brewer Sequential Yellow-Orange-Brown (9)’, ‘Brewer Sequential Yellow-Orange-Brown (8)’, ‘Brewer Sequential Yellow-Orange-Brown (7)’, ‘Brewer Sequential Yellow-Orange-Brown (6)’, ‘Brewer Sequential Yellow-Orange-Brown (5)’, ‘Brewer Sequential Yellow-Orange-Brown (4)’, ‘Brewer Sequential Yellow-Orange-Brown (3)’, ‘Brewer Sequential Blue-Purple (9)’, ‘Brewer Sequential Blue-Purple (8)’, ‘Brewer Sequential Blue-Purple (7)’, ‘Brewer Sequential Blue-Purple (6)’, ‘Brewer Sequential Blue-Purple (5)’, ‘Brewer Sequential Blue-Purple (4)’, ‘Brewer Sequential Blue-Purple (3)’, ‘Brewer Qualitative Accent’, ‘Brewer Qualitative Dark2’, ‘Brewer Qualitative Set2’, ‘Brewer Qualitative Pastel2’, ‘Brewer Qualitative Pastel1’, ‘Brewer Qualitative Set1’, ‘Brewer Qualitative Paired’, ‘Brewer Qualitative Set3’, ‘Traffic Lights’, ‘Traffic Lights For Deuteranopes’, ‘Traffic Lights For Deuteranopes 2’, ‘Muted Blue-Green’, ‘Green-Blue Asymmetric Divergent (62Blbc)’, ‘Asymmtrical Earth Tones (6_21b)’, ‘Yellow 15’, ‘Magma (matplotlib)’, ‘Inferno (matplotlib)’, ‘Plasma (matplotlib)’, ‘Viridis (matplotlib)’, ‘BlueObeliskElements’], rx=<param.reactive.reactive_ops object at 0x164489f50>)

Name of the colormap used to transform pixel value in color.

diffuse = param.Number(allow_refs=False, default=0.7, inclusive_bounds=(True, True), label=’Diffuse’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1649d02d0>, step=0.01)

Value to control the diffuse Lighting. It relies on both the light direction and the object surface normal.

display_volume = param.Boolean(allow_refs=False, default=True, label=’Display volume’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x164489f50>)

If set to True, the 3D representation of the volume is displayed using ray casting.

display_slices = param.Boolean(allow_refs=False, default=False, label=’Display slices’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1649d0b90>)

If set to true, the orthgonal slices in the three (X, Y, Z) directions are displayed. Position of each slice can be controlled using slice_(i,j,k) parameters.

edge_gradient = param.Number(allow_refs=False, bounds=(0, 1), default=0.4, inclusive_bounds=(True, True), label=’Edge gradient’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16241fad0>, step=0.01)

Parameter to adjust the opacity of the volume based on the gradient between voxels.

interpolation = param.Selector(allow_refs=False, default=’fast_linear’, label=’Interpolation’, names={}, nested_refs=False, objects=[‘fast_linear’, ‘linear’, ‘nearest’], rx=<param.reactive.reactive_ops object at 0x1649d30d0>)

interpolation type for sampling a volume. nearest interpolation will snap to the closest voxel, linear will perform trilinear interpolation to compute a scalar value from surrounding voxels. fast_linear under WebGL 1 will perform bilinear interpolation on X and Y but use nearest for Z. This is slightly faster than full linear at the cost of no Z axis linear interpolation.

mapper = param.Dict(allow_None=True, allow_refs=False, class_=<class ‘dict’>, label=’Mapper’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16478ae90>)

Lookup Table in format {low, high, palette}

max_data_size = param.Number(allow_refs=False, default=33.554432, inclusive_bounds=(True, True), label=’Max data size’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x16241fe50>)

Maximum data size transfer allowed without subsampling

nan_opacity = param.Number(allow_refs=False, bounds=(0.0, 1.0), default=1.0, inclusive_bounds=(True, True), label=’Nan opacity’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x164afcc10>)

Opacity applied to nan values in slices

origin = param.Tuple(allow_None=True, allow_refs=False, label=’Origin’, length=3, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x163731f10>)

render_background = param.Color(allow_named=True, allow_refs=False, default=’#52576e’, label=’Render background’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fb34cd0>)

Allows to specify the background color of the 3D rendering. The value must be specified as an hexadecimal color string.

rescale = param.Boolean(allow_refs=False, default=False, label=’Rescale’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1635ee750>)

If set to True the colormap is rescaled between min and max value of the non-transparent pixel, otherwise the full range of the pixel values are used.

shadow = param.Boolean(allow_refs=False, default=True, label=’Shadow’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15ad088d0>)

If set to False, then the mapper for the volume will not perform shading computations, it is the same as setting ambient=1, diffuse=0, specular=0.

sampling = param.Number(allow_refs=False, bounds=(0, 1), default=0.4, inclusive_bounds=(True, True), label=’Sampling’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1645a7250>, step=0.01)

Parameter to adjust the distance between samples used for rendering. The lower the value is the more precise is the representation but it is more computationally intensive.

spacing = param.Tuple(allow_refs=False, default=(1, 1, 1), label=’Spacing’, length=3, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15ad088d0>)

Distance between voxel in each direction

specular = param.Number(allow_refs=False, default=0.3, inclusive_bounds=(True, True), label=’Specular’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1645a7250>, step=0.01)

Value to control specular lighting. It is the light reflects back toward the camera when hitting the object.

specular_power = param.Number(allow_refs=False, default=8.0, inclusive_bounds=(True, True), label=’Specular power’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1649d1d90>)

Specular power refers to how much light is reflected in a mirror like fashion, rather than scattered randomly in a diffuse manner.

slice_i = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Slice i’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x15fb34cd0>)

Integer parameter to control the position of the slice normal to the X direction.

slice_j = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Slice j’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1649d2c10>)

Integer parameter to control the position of the slice normal to the Y direction.

slice_k = param.Integer(allow_refs=False, default=0, inclusive_bounds=(True, True), label=’Slice k’, nested_refs=False, rx=<param.reactive.reactive_ops object at 0x1645a7250>)

Integer parameter to control the position of the slice normal to the Z direction.

classmethod applies(obj: Any) float | bool | None[source]#

Returns boolean or float indicating whether the Pane can render the object.

If the priority of the pane is set to None, this method may also be used to define a float priority depending on the object being rendered.

clone(object: Any | None = None, **params) T[source]#

Makes a copy of the Pane sharing the same parameters.

Arguments#

object: Optional new object to render params: Keyword arguments override the parameters on the clone.

Returns#

Cloned Pane object

controls(parameters: list[str] = [], jslink: bool = True, **kwargs) BasePanel[source]#

Creates a set of widgets which allow manipulating the parameters on this instance. By default all parameters which support linking are exposed, but an explicit list of parameters can be provided.

Arguments#

parameters: list(str)

An explicit list of parameters to return controls for.

jslink: bool

Whether to use jslinks instead of Python based links. This does not allow using all types of parameters.

kwargs: dict

Additional kwargs to pass to the Param pane(s) used to generate the controls widgets.

Returns#

A layout of the controls

default_layout[source]#

alias of Row

embed(max_states: int = 1000, max_opts: int = 3, json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = False, states={}) None[source]#

Renders a static version of a panel in a notebook by evaluating the set of states defined by the widgets in the model. Note this will only work well for simple apps with a relatively small state space.

Arguments#

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for JSON filename

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=False)

Whether to report progress

states: dict (default={})

A dictionary specifying the widget values to embed for each widget

classmethod get_pane_type(obj: Any, **kwargs) type[PaneBase][source]#

Returns the applicable Pane type given an object by resolving the precedence of all types whose applies method declares that the object is supported.

Arguments#

obj (object): The object type to return a Pane type for

Returns#

The applicable Pane type with the highest precedence.

get_root(doc: Document | None = None, comm: Comm | None = None, preprocess: bool = True) Model[source]#

Returns the root model and applies pre-processing hooks

Arguments#

doc: bokeh.document.Document

Optional Bokeh document the bokeh model will be attached to.

comm: pyviz_comms.Comm

Optional pyviz_comms when working in notebook

preprocess: bool (default=True)

Whether to run preprocessing hooks

Returns#

Returns the bokeh model corresponding to this panel object

jscallback(args: dict[str, Any] = {}, **callbacks: str) Callback[source]#

Allows defining a JS callback to be triggered when a property changes on the source object. The keyword arguments define the properties that trigger a callback and the JS code that gets executed.

Arguments#

args: dict

A mapping of objects to make available to the JS callback

callbacks: dict

A mapping between properties on the source model and the code to execute when that property changes

Returns#

callback: Callback

The Callback which can be used to disable the callback.

Links properties on the this Reactive object to those on the target Reactive object in JS code.

Supports two modes, either specify a mapping between the source and target model properties as keywords or provide a dictionary of JS code snippets which maps from the source parameter to a JS code snippet which is executed when the property changes.

Arguments#

target: panel.viewable.Viewable | bokeh.model.Model | holoviews.core.dimension.Dimensioned

The target to link the value to.

code: dict

Custom code which will be executed when the widget value changes.

args: dict

A mapping of objects to make available to the JS callback

bidirectional: boolean

Whether to link source and target bi-directionally

links: dict

A mapping between properties on the source model and the target model property to link it to.

Returns#

link: GenericLink

The GenericLink which can be used unlink the widget and the target model.

Links the parameters on this Reactive object to attributes on the target Parameterized object.

Supports two modes, either specify a mapping between the source and target object parameters as keywords or provide a dictionary of callbacks which maps from the source parameter to a callback which is triggered when the parameter changes.

Arguments#

target: param.Parameterized

The target object of the link.

callbacks: dict | None

Maps from a parameter in the source object to a callback.

bidirectional: bool

Whether to link source and target bi-directionally

links: dict

Maps between parameters on this object to the parameters on the supplied object.

classmethod register_serializer(class_type, serializer)[source]#

Register a serializer for a given type of class. A serializer is a function which take an instance of class_type (like a vtk.vtkImageData) as input and return a numpy array of the data

save(filename: str | PathLike | IO, title: str | None = None, resources: Resources | None = None, template: str | Template | None = None, template_variables: dict[str, Any] = {}, embed: bool = False, max_states: int = 1000, max_opts: int = 3, embed_json: bool = False, json_prefix: str = '', save_path: str = './', load_path: str | None = None, progress: bool = True, embed_states: dict[Any, Any] = {}, as_png: bool | None = None, **kwargs) None[source]#

Saves Panel objects to file.

Arguments#

filename: str or file-like object

Filename to save the plot to

title: string

Optional title for the plot

resources: bokeh resources

One of the valid bokeh.resources (e.g. CDN or INLINE)

template:

passed to underlying io.save

template_variables:

passed to underlying io.save

embed: bool

Whether the state space should be embedded in the saved file.

max_states: int

The maximum number of states to embed

max_opts: int

The maximum number of states for a single widget

embed_json: boolean (default=True)

Whether to export the data to json files

json_prefix: str (default=’’)

Prefix for the auto-generated json directory

save_path: str (default=’./’)

The path to save json files to

load_path: str (default=None)

The path or URL the json files will be loaded from.

progress: boolean (default=True)

Whether to report progress

embed_states: dict (default={})

A dictionary specifying the widget values to embed for each widget

as_png: boolean (default=None)

To save as a .png. If None save_png will be true if filename is string and ends with png.

select(selector: type | Callable[[Viewable], bool] | None = None) list[Viewable][source]#

Iterates over the Viewable and any potential children in the applying the Selector.

Arguments#

selector: type or callable or None

The selector allows selecting a subset of Viewables by declaring a type or callable function to filter by.

Returns#

viewables: list(Viewable)

servable(title: str | None = None, location: bool | 'Location' = True, area: str = 'main', target: str | None = None) ServableMixin[source]#

Serves the object or adds it to the configured pn.state.template if in a panel serve context, writes to the DOM if in a pyodide context and returns the Panel object to allow it to display itself in a notebook context.

Arguments#

titlestr

A string title to give the Document (if served as an app)

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

area: str (deprecated)

The area of a template to add the component too. Only has an effect if pn.config.template has been set.

target: str

Target area to write to. If a template has been configured on pn.config.template this refers to the target area in the template while in pyodide this refers to the ID of the DOM node to write to.

Returns#

The Panel object itself

server_doc(doc: Document | None = None, title: str | None = None, location: bool | 'Location' = True) Document[source]#

Returns a serveable bokeh Document with the panel attached

Arguments#

docbokeh.Document (optional)

The bokeh Document to attach the panel to as a root, defaults to bokeh.io.curdoc()

titlestr

A string title to give the Document

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

docbokeh.Document

The bokeh document the panel was attached to

show(title: str | None = None, port: int = 0, address: str | None = None, websocket_origin: str | None = None, threaded: bool = False, verbose: bool = True, open: bool = True, location: bool | 'Location' = True, **kwargs) StoppableThread' | 'Server[source]#

Starts a Bokeh server and displays the Viewable in a new tab.

Arguments#

titlestr | None

A string title to give the Document (if served as an app)

port: int (optional, default=0)

Allows specifying a specific port

addressstr

The address the server should listen on for HTTP requests.

websocket_origin: str or list(str) (optional)

A list of hosts that can connect to the websocket. This is typically required when embedding a server app in an external web site. If None, “localhost” is used.

threaded: boolean (optional, default=False)

Whether to launch the Server on a separate thread, allowing interactive use.

verbose: boolean (optional, default=True)

Whether to print the address and port

openboolean (optional, default=True)

Whether to open the server in a new browser tab

locationboolean or panel.io.location.Location

Whether to create a Location component to observe and set the URL location.

Returns#

server: bokeh.server.Server or panel.io.server.StoppableThread

Returns the Bokeh server instance or the thread the server was launched on (if threaded=True)