Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: Add the ability to block callback signals#20816

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

Merged
timhoffm merged 1 commit intomatplotlib:masterfromgreglucas:callback-blocking
Aug 12, 2021

Conversation

greglucas
Copy link
Contributor

PR Summary

CallbackRegistry objects gain a context manager.block() method that can be used to temporarily block callback signals from being processed.

withcallbacks.block():callbacks.process("test")# Does nothingwithcallbacks.block(signal="test"):callbacks.process("test")# Does nothing

Closes#20802
Would help with disabling norm update signals in#19553

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • [N/A] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

Copy link
Member

@story645story645 left a comment

Choose a reason for hiding this comment

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

I think this could be really useful for debugging interactive stuff, so tentatively 👍

@greglucasgreglucasforce-pushed thecallback-blocking branch 2 times, most recently froma9680e7 toad95b35CompareAugust 10, 2021 23:13
Copy link
Member

@story645story645 left a comment

Choose a reason for hiding this comment

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

minor nits, but liking the new docs :)

@timhoffm
Copy link
Member

What do you think about naming thisblocked()? I like to use context manager names that are not imperative verbs and cannot be confused with simple functions. There is no general convention on this in the community, but I thinkwith callbacks.blocked() reads quite nicely.

story645 reacted with thumbs up emoji

@greglucas
Copy link
ContributorAuthor

@timhoffm, apparently there is a preferred convention and your suggestion lines up with that :)
https://www.python.org/dev/peps/pep-0343/#examples
I changed toblocked and moved the change note over to "next what's new" and included a short example there.

timhoffm reacted with thumbs up emoji

@story645
Copy link
Member

story645 commentedAug 11, 2021
edited
Loading

So is maybe annoying, but I think this needs a short API changes note too. only incompatible changes need API change notes.

Also, and I might be confused about the functionality here, but would it be possible for the what's new example to be slight less toy/use like one of the auto registrated callbacks or something?

timhoffm reacted with thumbs up emoji

CallbackRegistry objects now have a context manager .block()method that can be used to temporarily block callback signalsfrom being processed.
@greglucas
Copy link
ContributorAuthor

I came up with another toy-like example, but with interactivity on the figure canvas and disabling key-press events. Did you have another example/area in mind to apply this? It looks like the widgets keep their callbacks private in_observers, so I guess this doesn't really help the end user currently over there.

@story645
Copy link
Member

Using fig.canvas.callbacks is perfect - I was unsure whether the functionality extended to the fig callbacks and this clears it right up & I think would be a common use case 😄

@timhoffmtimhoffm added this to thev3.5.0 milestoneAug 12, 2021
@timhoffmtimhoffm merged commit495a985 intomatplotlib:masterAug 12, 2021
@greglucasgreglucas deleted the callback-blocking branchAugust 12, 2021 13:42
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@story645story645story645 approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.5.0
Development

Successfully merging this pull request may close these issues.

Add ability to disable callbacks temporarily
3 participants
@greglucas@timhoffm@story645

[8]ページ先頭

©2009-2025 Movatter.jp