Skip to content

Commit 4730545

Browse files
committed
Change how previewability is determined
1 parent f7a58b4 commit 4730545

File tree

3 files changed

+12
-16
lines changed

3 files changed

+12
-16
lines changed

pythreejs/_base/Three.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class ThreeWidget(Widget):
1111
_model_module = Unicode(npm_pkg_name).tag(sync=True)
1212
_model_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
1313

14+
_previewable = True
15+
1416
def __init__(self, **kwargs):
1517
super(ThreeWidget, self).__init__(**kwargs)
1618
self.on_msg(self._on_potential_ret_val)
@@ -38,6 +40,9 @@ def _on_ret_val(self, method_name, ret_val):
3840
self.log.info('%s() -> %s' % (method_name, ret_val))
3941

4042
def _ipython_display_(self, **kwargs):
41-
from IPython.display import display
42-
from .renderable import Preview
43-
return display(Preview(self), **kwargs)
43+
if self._previewable:
44+
from IPython.display import display
45+
from .renderable import Preview
46+
return display(Preview(self), **kwargs)
47+
else:
48+
return super(ThreeWidget, self)._ipython_display_(**kwargs)

pythreejs/animation/AnimationAction.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ class AnimationAction(AnimationActionBase, DOMWidget):
1818
_view_module = Unicode(npm_pkg_name).tag(sync=True)
1919
_view_module_version = Unicode(EXTENSION_VERSION).tag(sync=True)
2020

21+
_previewable = False
22+
2123
# Normally an int, but can also be inf:
2224
repititions = Union([CInt(), CFloat()], default_value=float('inf'), allow_none=False).tag(sync=True)
23-
24-
# Override default super MRO resolution (this is a mixin):
25-
def _ipython_display_(self, **kwargs):
26-
return Widget._ipython_display_(self, **kwargs)

pythreejs/core/BufferAttribute.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
@register
88
class BufferAttribute(BaseBufferAttribute):
99

10+
_previewable = False
11+
1012
def __init__(self, array=None, normalized=True, **kwargs):
1113
if array is not None:
1214
# Only include array in kwargs if supplied
@@ -16,12 +18,3 @@ def __init__(self, array=None, normalized=True, **kwargs):
1618
kwargs['normalized'] = normalized
1719
# NOTE: skip init of direct parent class on purpose:
1820
super(BaseBufferAttribute, self).__init__(**kwargs)
19-
20-
def _ipython_display_(self, **kwargs):
21-
# Preview widget doesn't make any sense for attributes
22-
from IPython.display import display
23-
data = {
24-
'text/plain': repr(self),
25-
}
26-
display(data, raw=True)
27-
self._handle_displayed(**kwargs)

0 commit comments

Comments
 (0)