8000 Fix toolmanager's destroy subplots in tk by ImportanceOfBeingErnest · Pull Request #14282 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Fix toolmanager's destroy subplots in tk #14282

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

Conversation

ImportanceOfBeingErnest
Copy link
Member

PR Summary

Fixes issue raised in https://stackoverflow.com/questions/56220821/python-matplotlib-removing-configure-subplots-tool-from-toolbar-in-matplotlib

Using the Tk backend in conjunction with the 'toolmanager' toolbar, the following line of code

 fig.canvas.manager.toolmanager.remove_tool('subplots')

would fail with an error

AttributeError: 'NoneType' object has no attribute 'destroy'

when being called before any window is instantiated.

This PR checks if self.window is None and only attempts to destroy existing windows.

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

8000
@timhoffm
Copy link
Member

Thanks.

@timhoffm timhoffm merged commit 7d92440 into matplotlib:master May 21, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request May 21, 2019
timhoffm added a commit that referenced this pull request May 21, 2019
…282-on-v3.1.x

Backport PR #14282 on branch v3.1.x (Fix toolmanager's destroy subplots in tk)
@ImportanceOfBeingErnest ImportanceOfBeingErnest deleted the fix-toolmngr-destroy-subplots branch August 2, 2019 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0