Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79a6426

Browse files
author
Massimiliano Tomassoli
committed
Improved compatibility with ipywidgtes and jupyter notebook
1 parent 512c401 commit 79a6426

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

plotly/widgets/graphWidget.js

Lines changed: 17 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plotly/widgets/graph_widget.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,16 @@
99

1010

1111
# TODO: protected imports?
12-
from IPython.html import widgets
13-
from IPython.utils.traitlets import Unicode
12+
try:
13+
import ipywidgets as widgets
14+
except ImportError:
15+
from IPython.html import widgets
16+
17+
try:
18+
from traitlets import Unicode
19+
except ImportError:
20+
from IPython.utils.traitlets import Unicode
21+
1422
from IPython.display import Javascript, display
1523

1624
import plotly.plotly.plotly as py
@@ -33,6 +41,7 @@ class GraphWidget(widgets.DOMWidget):
3341
Notebooks.
3442
"""
3543
_view_name = Unicode('GraphView', sync=True)
44+
_view_module = Unicode('GraphViewModule', sync=True)
3645
_message = Unicode(sync=True)
3746
_graph_url = Unicode(sync=True)
3847
_new_url = Unicode(sync=True)

0 commit comments

Comments
 (0)