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

moving toolmanager initialization up before toolbar #11694

Merged
merged 1 commit into from Jul 18, 2018

Conversation

fariza
Copy link
Member

@fariza fariza commented Jul 18, 2018

PR Summary

When running the toolmanager example with the tk backend we get the following error

09:40 $ python3 examples/user_interfaces/toolmanager_sgskip.py 
Traceback (most recent call last):
  File "examples/user_interfaces/toolmanager_sgskip.py", line 79, in <module>
    fig = plt.figure()
  File "/home/federico.ariza/workspace/matplotlib/lib/matplotlib/pyplot.py", line 521, in figure
    **kwargs)
  File "/home/federico.ariza/workspace/matplotlib/lib/matplotlib/backend_bases.py", line 3214, in new_figure_manager
    return cls.new_figure_manager_given_figure(num, fig)
  File "/home/federico.ariza/workspace/matplotlib/lib/matplotlib/backends/_backend_tk.py", line 1025, in new_figure_manager_given_figure
    manager = cls.FigureManager(canvas, num, window)
  File "/home/federico.ariza/workspace/matplotlib/lib/matplotlib/backends/_backend_tk.py", line 515, in __init__
    self.toolbar = self._get_toolbar()
  File "/home/federico.ariza/workspace/matplotlib/lib/matplotlib/backends/_backend_tk.py", line 535, in _get_toolbar
    toolbar = ToolbarTk(self.toolmanager, self.window)
  File "/home/federico.ariza/workspace/matplotlib/lib/matplotlib/backends/_backend_tk.py", line 816, in __init__
    ToolContainerBase.__init__(self, toolmanager)
  File "/home/federico.ariza/workspace/matplotlib/lib/matplotlib/backend_bases.py", line 3030, in __init__
    self.toolmanager.toolmanager_connect('tool_removed_event',
AttributeError: 'NoneType' object has no attribute 'toolmanager_connect'

In PR #11559 the tk toolbar initialization was moved up (packaging problem).
When working with the toolmanager, the toolmanager has to be initialized before the toolbar.
This fix just moves up the toolmanager initialization

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 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

@jklymak
Copy link
Member

jklymak commented Jul 18, 2018

Why wasn't this caught by tests?

@anntzer
Copy link
Contributor

anntzer commented Jul 18, 2018

Because test coverage of backend_tools is close to zero.

@fariza
Copy link
Member Author

fariza commented Jul 18, 2018

Are we testing the backends? this is related to specific TK implementation

@anntzer
Copy link
Contributor

anntzer commented Jul 18, 2018

@jklymak
Copy link
Member

jklymak commented Jul 18, 2018

There are various test_backendFoo in the test directory, but I don't know the details. But that need not hold up this PR if noone has a good idea how to add a test for this...

@jklymak jklymak added this to the v2.2.3 milestone Jul 18, 2018
@anntzer
Copy link
Contributor

anntzer commented Jul 18, 2018

Someone "just" needs to write them, the model in test_backends_interactive.py should be enough... (but we don't need to hold this PR up for that)

@tacaswell tacaswell merged commit 8f50633 into master Jul 18, 2018
@tacaswell tacaswell deleted the toolmanager-before-toolbar-tk branch July 18, 2018 17:10
@tacaswell
Copy link
Member

Thanks @fariza

Please try not to push branches to the main matplotlib repo!

@fariza
Copy link
Member Author

fariza commented Jul 18, 2018 via email

jklymak added a commit that referenced this pull request Jul 19, 2018
@tacaswell
Copy link
Member

@fariza No worries!

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

Successfully merging this pull request may close these issues.

None yet

4 participants