From 73ab4626d0091e445671d8def0db4b9950c67cb2 Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Sun, 21 May 2023 09:40:37 -0400 Subject: [PATCH] finishes #107, #119, #192 --- fastplotlib/graphics/_base.py | 4 ++++ fastplotlib/layouts/_gridplot.py | 5 ++++- fastplotlib/plot.py | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/fastplotlib/graphics/_base.py b/fastplotlib/graphics/_base.py index c1c3fbdfc..9eee05555 100644 --- a/fastplotlib/graphics/_base.py +++ b/fastplotlib/graphics/_base.py @@ -223,6 +223,10 @@ def link( self.registered_callbacks[event_type].append(callback_data) if bidirectional: + if event_type in PYGFX_EVENTS: + warn("cannot use bidirectional link for pygfx events") + return + target.link( event_type=event_type, target=self, diff --git a/fastplotlib/layouts/_gridplot.py b/fastplotlib/layouts/_gridplot.py index ab79a3804..f1db58044 100644 --- a/fastplotlib/layouts/_gridplot.py +++ b/fastplotlib/layouts/_gridplot.py @@ -166,7 +166,7 @@ def __init__( self._starting_size = size - def __getitem__(self, index: Union[Tuple[int, int], str]): + def __getitem__(self, index: Union[Tuple[int, int], str]) -> Subplot: if isinstance(index, str): for subplot in self._subplots.ravel(): if subplot.name == index: @@ -276,6 +276,9 @@ def show(self): return self.canvas + def close(self): + self.canvas.close() + def _get_iterator(self): return product(range(self.shape[0]), range(self.shape[1])) diff --git a/fastplotlib/plot.py b/fastplotlib/plot.py index 96b1ac8dc..2f5b61261 100644 --- a/fastplotlib/plot.py +++ b/fastplotlib/plot.py @@ -112,3 +112,6 @@ def show(self, autoscale: bool = True): self.canvas.set_logical_size(*self._starting_size) return self.canvas + + def close(self): + self.canvas.close()