-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix double picks. #19611
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
Fix double picks. #19611
Conversation
This fixes things locally for me both in my "minimal" (though from the test here it clearly wasn't as minimal as it could have been!) and in my real-world usecase subclassing |
@@ -2109,6 +2109,10 @@ def __init__(self, | |||
# a proxy property), but that actually need to be on the figure for | |||
# pickling. | |||
self._canvas_callbacks = cbook.CallbackRegistry() | |||
self._button_pick_id = self._canvas_callbacks.connect( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not particularly up on how the callback system works, but this seems intrusive in figure.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of #16220 was to move callback handling from the canvas to the figure (for reasons explained in that PR).
Ok, I still think this needs some thought. I think of a figure as a logical container for the axes and figure artists. If we change the semantics to also be the thing that handles mouse interactions that is a pretty big change and just doing it because of pickling, of all features, is irksome 😀 |
.. I mean I guess it has to pass CI... |
pick_events were previously incorrectly emitted twice due to the combination of two recent(ish) chnages: Figures now always start with a FigureCanvasBase attached -- eventually switching to a concrete subclass of FigureCanvasBase for display or saving --, and callbacks are now actually stored at the Figure level rather than the Canvas level. Hence, the button_pick_id callback (in charge of emitting picks) would previously be both registered both through the FigureCanvasBase and the concrete subclass. The fix is to also move that callback to the Figure level, so that each Figure only has one such callback.
Not sure why this didn't backport. @meeseeksdev backport to v3.4.x |
…611-on-v3.4.x Backport PR #19611 on branch v3.4.x (Fix double picks.)
pick_events were previously incorrectly emitted twice due to the
combination of two recent(ish) chnages: Figures now always start with a
FigureCanvasBase attached -- eventually switching to a concrete subclass
of FigureCanvasBase for display or saving --, and callbacks are now
actually stored at the Figure level rather than the Canvas level.
Hence, the button_pick_id callback (in charge of emitting picks) would
previously be both registered both through the FigureCanvasBase and the
concrete subclass. The fix is to also move that callback to the Figure
level, so that each Figure only has one such callback.
PR Summary
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).