From 3072224635fb88a747eaa4e46bde66001a60086d Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Tue, 17 May 2022 01:10:26 +0200 Subject: [PATCH] Ensure that HoloViews callback events are not auto-dispatched --- panel/pane/holoviews.py | 7 +++++-- panel/pane/plot.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/panel/pane/holoviews.py b/panel/pane/holoviews.py index ce5c60b470..e56041376d 100644 --- a/panel/pane/holoviews.py +++ b/panel/pane/holoviews.py @@ -281,8 +281,11 @@ def _get_model(self, doc, root=None, parent=None, comm=None): def _get_pane(self, backend, state, **kwargs): pane_type = self._panes.get(backend, Pane) - if isinstance(pane_type, type) and issubclass(pane_type, Matplotlib): - kwargs['tight'] = True + if isinstance(pane_type, type): + if issubclass(pane_type, Matplotlib): + kwargs['tight'] = True + if issubclass(pane_type, Bokeh): + kwargs['autodispatch'] = False return pane_type(state, **kwargs) def _render(self, doc, comm, root): diff --git a/panel/pane/plot.py b/panel/pane/plot.py index c728a7cf86..e562e3dfa6 100644 --- a/panel/pane/plot.py +++ b/panel/pane/plot.py @@ -57,6 +57,10 @@ class Bokeh(PaneBase): >>> Bokeh(some_bokeh_figure) """ + autodispatch = param.Boolean(default=True, doc=""" + Whether to automatically dispatch events inside bokeh on_change + and on_event callbacks in the notebook.""") + theme = param.ClassSelector(default=None, class_=(Theme, str), doc=""" Bokeh theme to apply to the plot.""") @@ -114,7 +118,7 @@ def _get_model(self, doc, root=None, parent=None, comm=None): continue properties[p] = value model.update(**properties) - if comm: + if comm and self.autodispatch: self._wrap_bokeh_callbacks(root, model, doc, comm) ref = root.ref['id']