8000 Undeprecate Cursor event handlers by ksunden · Pull Request #25129 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Undeprecate Cursor event handlers #25129

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

Merged
merged 6 commits into from
Feb 6, 2023
Merged

Conversation

ksunden
Copy link
Member
@ksunden ksunden commented Feb 2, 2023
  • Revert "Fix deprecations of *Cursor widget event handlers"
  • Revert: Deprecate access to Cursor/MultiCursor event handlers.
  • Add simulated mouse events to cursor demos
  • remove calls to set_visible(False)

Closes #25107

PR Summary

The event handlers were deprecated for mpl 3.7 in #19763 (with correction for the deprecation notices in #24750)
This has not been released as a final matplotlib version (only the rc).

However, one of examples demonstrated subclassing these classes specifically to override these methods.
The callbacks registered internally were for the privitized version of the functions, thus the overrides did nothing.
Given that it is suggested in our docs, we determiened in #25107 that we should undeprecate these methods.

The original PR kept the calls to set_visible(False) in the un-prefixed versions of clear for Cursor and MultiCursor.
Because clear is registered as a callback on a draw event, this was causing the cursor to disappear on the nbagg backend.

clear is not actually run in our test suite, as observed on codecov.

In ad hoc testing, removing seemed to have limited impact on the qt backend (seemed to function as expected).
The problem from #19763 was reintroduced for the nbagg backend if the set_visible(False) was included.

So I removed those lines entirely for the undeprecation.
This feels odd, as I may have expected the clear function to explicitly turn off the cursor visibility.
But as far as I can tell, it works like I'd expect.

I suspect in the narrow case of a user calling clear directly (as opposed to relying on the internal callbacks)
it may not actually remove the lines and thus be unexpected behavior.
But I have no examples of doing such, and in most cases if the cursor was showing to begin with, the mouse is over the axes, and will cause the cursor to show up as soon as it moves anyway, I'd think.

Anywho, while working on these, figured I'd also add a simulted mouse event to the examples so that the docs show what they actually do (if not interactively still) a bit more.
I did so using _process() on the MouseEvent because that is what is done in our tests for simulating mouse events.
I could have made the mouse event and passed it directly to the callback method, I think, which would have avoided using an _ method in our example.

@anntzer suggested perhaps removing the widgets/annotated_cursor example all together because event_handlers/cursor_demo does effectively the same thing but in less code.

@tacaswell voted in favor of keeping both for the time being (though did check that they are cross linked to each other).

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • New plotting related features are documented with examples.

Release Notes

  • New features are marked with a .. versionadded:: directive in the docstring and documented in doc/users/next_whats_new/
  • API changes are marked with a .. versionchanged:: directive in the docstring and documented in doc/api/next_api_changes/
  • Release notes conform with instructions in next_whats_new/README.rst or next_api_changes/README.rst

@tacaswell tacaswell added this to the v3.7.0 milestone Feb 2, 2023
Copy link
Member
@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am convinced by the observation that as soon as the mouse is moved into the axes the cursor will be made visible again and already becomes invisible if the mouse moves out.

While there is a risk of breakage here, I think that it is less this way than with what is on main now.

@ksunden ksunden force-pushed the undeprecate_cursor branch from d0af10f to d8f7072 Compare February 2, 2023 18:39
< 8000 /div>
Co-authored-by: Thomas A Caswell <tcaswell@gmail.com>
@ksunden ksunden force-pushed the undeprecate_cursor branch from d8f7072 to 17542db Compare February 2, 2023 18:43
@tacaswell
Copy link
Member

The current state works for me running python examples/widgets/annotated_cursor.py

@ksunden ksunden added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Feb 3, 2023
@anntzer anntzer merged commit ce21d72 into matplotlib:main Feb 6, 2023
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Feb 6, 2023
ksunden pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Feb 6, 2023
Trying to run the example prior to the PR would result in exceptions
being thrown on mouse moves.

Manual backport of matplotlib#25106 rolled into backport of matplotlib#25129 (backport pr matplotlib#25160)
ksunden added a commit that referenced this pull request Feb 7, 2023
…129-on-v3.7.x

Backport PR #25129 on branch v3.7.x (Undeprecate Cursor event handlers)
@ksunden ksunden mentioned this pull request Feb 20, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Doc]: annotated_cursor example seems broken
3 participants
0