Skip to content

Commit

Permalink
add close option
Browse files Browse the repository at this point in the history
  • Loading branch information
j042 committed Jan 26, 2024
1 parent 5592b3c commit f3658f3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
18 changes: 15 additions & 3 deletions gustaf/helpers/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,34 @@ def show(
if len(args) != 0 or len(kwargs) != 0:
self._logd(f"*args ({args}) and **kwargs ({kwargs}) ignored")

# this converts vedo plotter to k3d plot.
# after this, vedo plotter has no relevance to what you see
self[self._at_get_location(at)] = self.vedo_plotters[at].show(
list_of_showables,
interactive=interactive,
camera=camera,
axes=axes,
)

def display(self):
def display(self, close=True):
"""Display the plotter.
This is needed in case the plotter is the last thing in a cell. In that
case the IPython will try to call this function to display this.
"""
display(self)

# we add option to close here, as we set default_autoclose = False
if close:
self.clear()
self.close()

def clear(self, *args, **kwargs):
"""Clear the plotters."""
for renderer in self.vedo_plotters:
renderer.clear(*args, deep=True, **kwargs)
for v_plotter in self.vedo_plotters:
v_plotter.clear(*args, deep=True, **kwargs)

def close(self):
"""Closes all vedo.Plotters"""
for v_plotter in self.vedo_plotters:
v_plotter.close()
7 changes: 2 additions & 5 deletions gustaf/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ def __call__(self, *args, **kwargs):
is_ipython = False


def show(
*args,
**kwargs,
):
def show(*args, **kwargs):
"""`vedo.show` wrapper. Each args represent one section of window. In other
words len(args) == N, where N corresponds to the parameter for vedo.show().
Expand Down Expand Up @@ -222,7 +219,7 @@ def cam_tuple_to_list(dict_cam):
)

if is_ipython:
plt.display()
plt.display(close=close)
return None

if interact and not offs:
Expand Down

0 comments on commit f3658f3

Please sign in to comment.