napari / napari-animation

A napari plugin for making animations
https://napari.github.io/napari-animation/
Other
79 stars 27 forks source link

Scripting first then using the widget isn't working well #52

Closed Fifourche closed 3 years ago

Fifourche commented 3 years ago

When first adding key frames via scripting, the widget doesn't work properly ;

I actually discovered that while running the example of scripting code of the project (in the README), and instantiating the widget.

Some code to reproduce this :

import napari
from napari_animation import AnimationWidget
from skimage.data import cells3d

cells = cells3d()[:, 1]  # get some data

# Launch viewer to view data
viewer = napari.view_image(cells, colormap='magma')

# Instantiate the animation widget
animation_widget = AnimationWidget(viewer)
viewer.window.add_dock_widget(animation_widget, area='right')
animation = animation_widget.animation

viewer.dims.ndisplay = 3
viewer.camera.angles = (0.0, 0.0, 90.0)
animation.capture_keyframe()
viewer.camera.zoom = 2.4
animation.capture_keyframe()
viewer.camera.angles = (-7.0, 15.7, 62.4)
animation.capture_keyframe(steps=60)
viewer.camera.angles = (2.0, -24.4, -36.7)
animation.capture_keyframe(steps=60)
viewer.reset_view()
viewer.camera.angles = (0.0, 0.0, 90.0)
animation.capture_keyframe()
alisterburt commented 3 years ago

Thanks for the report @Fifourche - I think this will be solved by changing how events are hooked up (some discussion in #50, #51), if you want to take a look please do!

alisterburt commented 3 years ago

Strange - despite instantiating the widget before capturing key-frames the capture_keyframe callback is never called... trying to figure out what's going on

Fifourche commented 3 years ago

Will this callback be more than the capture button ? Also I think one of the problems is that the key frames list, the delete button and the control buttons are all set to disabled at initialization, regardless of the number of key frames already captured.

It's true that changing the events will help a lot I guess ! :) by the way, I noticed that in some places of the naparicode, Signal from pyqt5 is used for generating events, while napari.Event is used in other places ; is there a better choice here, like sticking to Event types ?

alisterburt commented 3 years ago

I imagine it will only be used for the capture button! You're right about the init for sure 😄

I'm not sure what the story is with Event vs direct use of Signal but if I want to add events to something I usually add them to an existing EventEmitter - I would say guess that sticking with the napari objects ensures compatibility with napari in case we move away from a Qt GUI in the future

The event system is actually from vispy it seems, cool!

alisterburt commented 3 years ago

closed by #73