Skip to content

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

@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