Skip to content

Commit

Permalink
Merge pull request #386 from vidartf/fixes
Browse files Browse the repository at this point in the history
Fixes for 2.4.0
  • Loading branch information
vidartf authored Aug 25, 2022
2 parents 00626ce + ed4e994 commit 8957832
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
1 change: 1 addition & 0 deletions docs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: pythreejs_docs
channels:
- conda-forge
dependencies:
- ipydatawidgets>=4.3.2
- python=3.10
- nodejs
- numpy
Expand Down
42 changes: 25 additions & 17 deletions pythreejs/_base/Three.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,29 @@ def _on_ret_val(self, method_name, ret_val):
"""Message callback used internally for logging exec returns"""
self.log.info('%s() -> %s' % (method_name, ret_val))

def _repr_mimebundle_(self, **kwargs):
if self._previewable:
from IPython.display import display
from .renderable import Preview
plaintext = repr(self)
if len(plaintext) > 110:
plaintext = plaintext[:110] + '…'
preview = Preview(self)
return {
'text/plain': plaintext,
'application/vnd.jupyter.widget-view+json': {
"version_major": 2,
"version_minor": 0,
"model_id": preview._model_id
if hasattr(Widget, "_ipython_display_"): # ipywidgets < 8.0.0
def _ipython_display_(self, **kwargs):
if self._previewable:
from IPython.display import display
from .renderable import Preview
return display(Preview(self), **kwargs)
else:
return super(ThreeWidget, self)._ipython_display_(**kwargs)
else:
def _repr_mimebundle_(self, **kwargs):
if self._previewable:
from .renderable import Preview
plaintext = repr(self)
if len(plaintext) > 110:
plaintext = plaintext[:110] + '…'
preview = Preview(self)
return {
'text/plain': plaintext,
'application/vnd.jupyter.widget-view+json': {
"version_major": 2,
"version_minor": 0,
"model_id": preview._model_id
}
}
}
else:
return super(ThreeWidget, self)._repr_mimebundle_(**kwargs)
else:
return super(ThreeWidget, self)._repr_mimebundle_(**kwargs)
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
'ipywidgets>=7.2.1',
'ipydatawidgets>=1.1.1',
'numpy',
'traitlets',
],
'extras_require': {
'test': [
Expand Down

0 comments on commit 8957832

Please sign in to comment.