Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix merge conflicts
  • Loading branch information
kushalkolar committed Dec 11, 2022
commit 7630c9711e56eb9530f55bbbca65c90c6ce234be
34 changes: 32 additions & 2 deletions fastplotlib/layouts/_subplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from wgpu.gui.auto import WgpuCanvas
from warnings import warn
import numpy as np
from math import copysign


class Subplot:
Expand Down Expand Up @@ -113,8 +114,13 @@ def animate(self, canvas_dims: Tuple[int, int] = None):
for dv in self.docked_viewports.values():
dv.render()

def add_animations(self, funcs: List[callable]):
self._animate_funcs += funcs
def add_animations(self, *funcs: callable):
for f in funcs:
if not callable(f):
raise TypeError(
f"all positional arguments to add_animations() must be callable types, you have passed a: {type(f)}"
)
self._animate_funcs += funcs

def add_graphic(self, graphic, center: bool = True):
if graphic.name is not None: # skip for those that have no name
Expand Down Expand Up @@ -182,9 +188,33 @@ def set_grid_visibility(self, visible: bool):
else:
self.scene.remove(self._grid)

def get_graphics(self):
return self._graphics

def remove_graphic(self, graphic):
self.scene.remove(graphic.world_object)

def __getitem__(self, name: str):
for graphic in self._graphics:
if graphic.name == name:
return graphic

graphic_names = list()
for g in self._graphics:
graphic_names.append(g.name)
raise IndexError(f"no graphic of given name, the current graphics are:\n {graphic_names}")

def __repr__(self):
newline = "\n "
if self.name is not None:
return f"'{self.name}' fastplotlib.{self.__class__.__name__} @ {hex(id(self))}\n" \
f"Graphics: \n " \
f"{newline.join(graphic.__repr__() for graphic in self.get_graphics())}"
else:
return f"fastplotlib.{self.__class__.__name__} @ {hex(id(self))} \n" \
f"Graphics: \n " \
f"{newline.join(graphic.__repr__() for graphic in self.get_graphics())}"


class _DockedViewport:
_valid_positions = [
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.