-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[ENH]: Event to notify non-motion after a specific amount of time #29162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The general approach I think you would have to take is have a callback on I suggest starting with https://matplotlib.org/stable/api/backend_bases_api.html#matplotlib.backend_bases.FigureCanvasBase.new_timer to get timers integrated with the GUI toolkit and to make sure that the callbacks run on the main thread (threading.Timer will likely run into some "fun" thread related issues). I don't see any technical reason why this can not be implemented outside of the core library, but I also suspect it will be subtle enough that it would be worth pulling it into core once it is working. Is there prior art of APIs for hover that should be used as inspiration? |
Going through matplotlib’s event mechanism feels relatively heavy. The underlying GUI frameworks should have appropriate events that we could subscribe to (e.g. QEvent::Tooltip for Qt). I’d expect that to be more efficient than restarting a timer through a Python function on every motion event. See also #23378. @albavilanova Could you describe the kind of annotations in your use case? Is it a simple text or a more complex annotation? Is it a constant annotation per Artist (Line, Rectangle…) or e.g. per data point / depending on the position within a rectangle, …)? Is the data constant and could be precomputed/provided via a high-level API such as |
It is simple text, generated using annotate, but the text isn't static as it is computed on-the-fly. We have given it a go with Tooltip from Qt and it seems to work much faster keeping motion_notify_event. Feel free to close the issue, thank you! |
On reflection I agree with @timhoffm . |
I'm going to close this as a duplicate of #23378. |
Would it worth considering such an event ("non-motion" event) for widgets or selectors? This would a significant improvement for situation where the callback connected to the selectors are too slow to be live: for example instead of connecting the callback on |
Problem
Hi all,
I hope you are doing well.
I've been reading the documentation page on event handling and haven't found an event to detect if the mouse is not moving for some time (1 second or something configurable).
We would like to have this feature to be able to get annotations on hover on our plot only when the user stops moving the mouse, instead of when the user moves the mouse with 'motion_notify_event' as we are doing it now, which we think makes our application run more slowly.
If you have any question let me know.
Thanks,
Albs
Proposed solution
No response
The text was updated successfully, but these errors were encountered: