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

Add throttle/debounce #55

Closed mwcraig closed 4 years ago

mwcraig commented 4 years ago

Closes #54 by adding throttle/debounce.

Brief useage:

e = Event()
# Choose method of decreasing event rate, either 'throttle' or 'debounce' or None.
e.throttle_or_debounce = 'throttle'

# Set the throttle or debounce time in millseconds (must be an non-negative integer)
e.wait = 100

# If you set wait without setting throttle/debounce first then throttle is used.

# Set the wait back to zero to turn off throttle/debounce
e.wait = 0
mwcraig commented 4 years ago

@banesullivan -- I don't usually get around to adding code this quick but your suggestion came just before SciPy 2020, so this was a good excuse to do some work on the package. Hoping to add some additional documentation and automate the testing before merging.

Let me know if you have time to give this a try.

banesullivan commented 4 years ago

Tried, but I can't get the nbextension to enable with a developer install 😞

nbextensions are always a pain for me

mwcraig commented 4 years ago

Are you using classic notebook or lab?

If the dev install is a hassle, though, I can merge this later and do a beta release on pypi for you to install.

banesullivan commented 4 years ago

I'm trying with just classic notebook to keep it simple

mwcraig commented 4 years ago

Odd, that case should work with pip install -e .. What do you get from jupyter nbextension list?

banesullivan commented 4 years ago

I created a fresh virtual environment, pip installed jupyter and a few of my projects depends, followed the dev install instructions for ipyevents, then:

$ jupyter nbextension list
Known nbextensions:
  config dir: /Users/bane/.jupyter/nbconfig
    notebook section
      ipyevents/extension disabled
  config dir: /Users/bane/anaconda3/envs/ipye/etc/jupyter/nbconfig
    notebook section
      ipycanvas/extension  enabled
      - Validating: OK
      jupyter-js-widgets/extension  enabled
      - Validating: OK
      ipyevents/extension  enabled
      - Validating: problems found:
        - require?  X ipyevents/extension

I'm just having trouble getting the extension to work... I'm not too sure how to debug these issues and I totally don't want to eat up your time with it either.

I may try this again in a Docker container to remove any complications from my local set up and hopefully that'll work

mwcraig commented 4 years ago

This looks like an issue with the ipyevents nbextension 😬. Investigating locally...

mwcraig commented 4 years ago

@banesullivan -- ok you should be able to try it now. I had accidentally the extension file 🤦‍♂️

banesullivan commented 4 years ago

Woohoo! It seems to be working great!!

mwcraig commented 4 years ago

Excellent, I'll work on a bit of documentation later today then merge and release