Skip to content

Commit

Permalink
fix: use last focused/resized view to determine shape of BqplotImageView
Browse files Browse the repository at this point in the history
  • Loading branch information
iisakkirotko committed Dec 11, 2024
1 parent 1876875 commit e90f0ba
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions glue_jupyter/bqplot/image/viewer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime

from glue.viewers.image.composite_array import CompositeArray
from bqplot_image_gl.viewlistener import ViewListener

Expand Down Expand Up @@ -81,9 +83,14 @@ def _reset_limits(self, old, new):
self.state.reset_limits()

def _on_view_change(self, *args):
views = sorted(self._vl.view_data)
# Order view_data by focused_at and then resized_at, latest change first
views = sorted(
self._vl.view_data.values(),
key=lambda x: (datetime.fromisoformat(x['focused_at']), datetime.fromisoformat(x['resized_at'])),
reverse=True
)
if len(views) > 0:
first_view = self._vl.view_data[views[0]]
first_view = views[0]
self.shape = (int(first_view['height']), int(first_view['width']))
self._composite_image.update()
else:
Expand Down

0 comments on commit e90f0ba

Please sign in to comment.