Skip to content

Commit

Permalink
Improved support for ipywidgets>=8.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 3, 2023
1 parent 12e2810 commit b6b6434
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion panel/io/ipywidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
from ..util import classproperty
from .state import set_curdoc, state

try:
# Support for ipywidgets>=8.0.5
import comm

from comm.base_comm import BaseComm

class DummyComm(BaseComm):
def publish_msg(self, *args, **kwargs): pass

comm.create_comm = lambda *args, **kwargs: DummyComm(target_name='panel-temp-comm', primary=False)
except Exception:
pass

def _get_kernel(cls=None, doc=None):
doc = doc or state.curdoc
Expand All @@ -48,9 +60,10 @@ def _on_widget_constructed(widget, doc=None):
return
widget._document = doc
kernel = _get_kernel(doc=doc)
if widget.comm and isinstance(widget.comm.kernel, PanelKernel):
if widget.comm and widget.comm.target_name != 'panel-temp-comm' and isinstance(widget.comm.kernel, PanelKernel):
return
args = dict(
kernel=kernel,
target_name='jupyter.widget', data={}, buffers=[],
metadata={'version': __protocol_version__}
)
Expand Down

0 comments on commit b6b6434

Please sign in to comment.