Skip to content

Commit

Permalink
Viewer.show: run IPython's display() directly
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Aug 27, 2024
1 parent de6c8f9 commit 0aa3f12
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions octarine/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,8 @@ class Viewer:
Controller type to use. Defaults to "trackball".
show : bool
Whether to immediately show the viewer. A few notes:
1. This has no effect in Jupyter. There you will have to call ``.show()``
manually on the last line of a cell for the viewer to appear.
2. When running in a non-interactive script or REPL, you have to also start
the event loop manually.
See the `Viewer.show()` method for more information.
1. When running in a non-interactive script or REPL, you have to also start
the event loop manually. See the `Viewer.show()` method for more information.
**kwargs
Keyword arguments are passed through to ``WgpuCanvas``.
Expand Down Expand Up @@ -777,19 +774,23 @@ def show(self, use_sidecar=False, toolbar=False, start_loop=False):
" >>> v.show()\n"
" >>> run()\n\n" # do not remove the \n\n here
)
# For Jupyter we need to wrap the canvas in a widget
else:
# if not hasattr(self, 'widget'):
from .jupyter import JupyterOutput
from IPython.display import display

# Construct the widget
self.widget = JupyterOutput(
self,
use_sidecar=use_sidecar,
toolbar=toolbar,
sidecar_kwargs={"title": self._title},
)
return self.widget
if not hasattr(self, "widget"):
self.widget = JupyterOutput(
self,
use_sidecar=use_sidecar,
toolbar=toolbar,
sidecar_kwargs={"title": self._title},
)

# This will display the viewer right here and there
display(self.widget)


def show_message(
self, message, position="top-right", font_size=20, color=None, duration=None
Expand Down

0 comments on commit 0aa3f12

Please sign in to comment.