Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Fix double picks.#19611
Uh oh!
There was an error while loading.Please reload this page.
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 infigure.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 thecombination of two recent(ish) chnages: Figures now always start with aFigureCanvasBase attached -- eventually switching to a concrete subclassof FigureCanvasBase for display or saving --, and callbacks are nowactually stored at the Figure level rather than the Canvas level.Hence, the button_pick_id callback (in charge of emitting picks) wouldpreviously be both registered both through the FigureCanvasBase and theconcrete subclass. The fix is to also move that callback to the Figurelevel, 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.xBackport 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).