The Wayback Machine - https://web.archive.org/web/20240106173905/https://github.com/matplotlib/matplotlib/pull/27550
Skip to content
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

ENH: add public API to CallbackRegistry to bulk-clear callbacks #27550

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tacaswell
Copy link
Member

This adds known_cid as a helper to get all currently known cids and and clear_above to remove all newer cids.

Partially addresses #27508 by adding public API for removing newly added callbacks

Usage would look like:

fig, ax = plt.subplots()
max_cid = fig.canvas.callbacks.known_cid
# stuff
fig.canvas.callbacks.clear_above(max_cid)

If we want this, it needs tests and docs, but putting this up for discussion.

This adds known_cid as a helper to get all currently known cids and
and clear_above to remove all newer cids.
@anntzer
Copy link
Contributor

anntzer commented Dec 20, 2023

FWIW I would much rather move cids towards being opaque objects. (For example they could keep a weakref to their owning registry so that one can just do cid.remove())
I guess technically they could be opaque but ordered objects (or even int subclasses...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants