On release slider event?
See original GitHub issueI would like to have access to a on_mouse_release
event for a IntSlider
, while still having continuous_update=True
.
I am slicing through a 3D data cube with ipyvolume
and using a slider to control the z
coordinate of the slice. Updating the slice and its colors every single step of the way slows down the performance quite a lot.
I would like to do something similar to what Paraview does, where while I interact with the slider, I am only moving an outline (in red on my figure) of the slice, and once I relase the slider, then update the position of the real slice and its colors. Moving the outline is very cheap.
Hence I still need to have the slider move the outline (update_outline()
) in continuous_update
but then trigger another function (update_slice()
) once I relase the mouse button.
I tried playing around with linking a first slider in continuous_update=True
to a second slider in continuous_update=False
which would then trigger the update_slice()
, but linking the values means that the second slider still considers every step to be a value change and triggers update_slice()
every time.
I would basically need to have something like
sl = IntSlider(min=0, max=nz-1, continuous_update=True)
sl.observe(update_outline, names="value")
sl.on_mouse_release(update_slice, names="value")
I found in the documentation that you can send more than just the value
to the observer function. Apparently, setting names
and type
to All
should capture all events, and maybe there is something I could use in there, but I have not been successful in trying to use this.
When I tried
sl = IntSlider(min=0, max=nz-1, continuous_update=True)
sl.observe(update_outline, names="All", type="All")
nothing happens, the function update_outline
is never called (I had a print
statement also in that function which never prints).
I tried to look around the documentation and the web for an example of using names="All", type="All"
but found nothing.
Any help is very much appreciated!
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (8 by maintainers)
Top GitHub Comments
I can look into implementing a “debounce” pattern. While talking with @martinRenou, it could be useful to have it on both sides:
related to this, somebody mentioned the
continuous_update
parameter and in my case it waits to send the events until the user stops dragging the slider but it sends all the changes! not just the last one, is there a way to prevent this or that’s the expected behaviour?EDIT: nevermind, I just need to access the new value but still the whole chain of old values is sent to the kernel and resulted in a lot of traffic so I had to increase
NotebookApp.iopub_data_rate_limit
. It would be a good idea to implement what you guys already started talking about or even better have a “mute” property so some events are not sent as a whole if there is heavy interaction in the front end.