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

Removing figureoptions from subclassed NavigationToolbar2QT #4574

Closed
ghost opened this issue Jul 1, 2015 · 6 comments
Closed

Removing figureoptions from subclassed NavigationToolbar2QT #4574

ghost opened this issue Jul 1, 2015 · 6 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Jul 1, 2015

Subclassing a NavigationToolbar2QT allows one to add and remove buttons on the navigation bar. However, the figure options menu remains and cannot be removed like the other default buttons. I was able to construct a temporary solution by importing matplotlib.backends.backend_qt and setting figureoptions = None. Please see below example:

from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT
import matplotlib.backends.backend_qt5 as backend


class MplToolbar(NavigationToolbar2QT):
    def __init__(self, canvas_, parent_):
        backend.figureoptions = None  # Monkey patched to kill the figure options button on matplotlib toolbar

        self.toolitems = (
            ('Home', 'Reset original view', 'home', 'home'),
            ('Back', 'Back to previous view', 'back', 'back'),
            ('Forward', 'Forward to next view', 'forward', 'forward'),
            (None, None, None, None),
            ('Pan', 'Pan axes with left mouse, zoom with right', 'move', 'pan'),
            ('Zoom', 'Zoom to rectangle', 'zoom_to_rect', 'zoom'),
            (None, None, None, None),
            ('Save', 'Save the current image', 'filesave', 'save_figure'),
            )
        NavigationToolbar2QT.__init__(self, canvas_, parent_)

Is there another, better solution out there? Appreciated!

@tacaswell
Copy link
Member

We are in the process of completely overhauling how the toolbars are build and managed.

attn @OceanWolf @fariza

@tacaswell tacaswell reopened this Jul 1, 2015
@tacaswell
Copy link
Member

Sorry, hit the wrong button, did not mean to close this issue!

@OceanWolf
Copy link
Contributor

@jclark754 short answer right now no, but in the next release yes.

As @tacaswell explains, we currently overhaul all of the Toolbar #3652 (and Window #4143) logic, introducing a completely new Toolbar/Tool system allowing you to do all the kind of tool changes you want and in a 100% backend neutral way.

If you use the bleeding edge master branch then you can already use the overhauled toolbars on the GTK3 and Tk backends, however the Window refactor (not yet in master) will make a few small adjustments, fixing a few of the remaining issues we had with the new toolbar, after that the other backends should follow quite rapidly, ready in time for the next release.

@OceanWolf OceanWolf added the MEP: MEP22 tool manager label Jul 1, 2015
@tacaswell tacaswell added this to the proposed next point release milestone Jul 7, 2015
@fariza
Copy link
Member

fariza commented Sep 10, 2015

@jclark754 did @OceanWolf comment answer your question?

@ghost
Copy link
Author

ghost commented Sep 14, 2015

@fariza yep, sounds good.

@fariza
Copy link
Member

fariza commented Sep 14, 2015

Closing this, as the changes are already in place for this to work with the new Toolbar and Toolmanager

@fariza fariza closed this as completed Sep 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants