mwcraig / ipyevents

A custom widget for returning mouse and keyboard events to Python. Documentation:
https://ipyevents.readthedocs.io/en/latest/index.html
BSD 3-Clause "New" or "Revised" License
112 stars 27 forks source link

Throttling? #54

Closed banesullivan closed 4 years ago

banesullivan commented 4 years ago

Is it possible to throttle the message queue? Any tips on how to do this?

I tried overriding the on_dom_event (the function being passed) with the throttler in https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Events.html#Throttling but it doesn't work here?

See https://github.com/Kitware/ipyvtk-simple/pull/8

mwcraig commented 4 years ago

It is not currently possible to throttle but I'll see if I can add that today 😀 . I may need some help from @martinRenou if I can't figure out how to do it. @martinRenou is right that iwork needs to be done on the javascript side to make this happen, though it will be controllable from the python side.

mwcraig commented 4 years ago

Also, thanks for reporting this!

mwcraig commented 4 years ago

I tried overriding the on_dom_event (the function being passed) with the throttler in https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Events.html#Throttling but it doesn't work here?

That example is useful for throttling calls from the python side of a widget. In this case the issue is that the javascript side of ipyevents is passing in every mouse move event with no throttling. If the event results in an expensive computation on the python side then you will see lag, especially if the python result also has to be transmitted back to javascript.

banesullivan commented 4 years ago

@mwcraig, thanks for jumping on this! Do let me know when you think you have something and I can give it a try