Base class for the navigation cursor, version 2. Backends must implement a canvas that handles connections for 'button_press_event' and 'button_release_event'. See :meth:`FigureCanvasBase.mpl_connect` for more information. They must also define :meth:`save_figure`
| 2919 | |
| 2920 | |
| 2921 | class NavigationToolbar2: |
| 2922 | """ |
| 2923 | Base class for the navigation cursor, version 2. |
| 2924 | |
| 2925 | Backends must implement a canvas that handles connections for |
| 2926 | 'button_press_event' and 'button_release_event'. See |
| 2927 | :meth:`FigureCanvasBase.mpl_connect` for more information. |
| 2928 | |
| 2929 | They must also define |
| 2930 | |
| 2931 | :meth:`save_figure` |
| 2932 | Save the current figure. |
| 2933 | |
| 2934 | :meth:`draw_rubberband` (optional) |
| 2935 | Draw the zoom to rect "rubberband" rectangle. |
| 2936 | |
| 2937 | :meth:`set_message` (optional) |
| 2938 | Display message. |
| 2939 | |
| 2940 | :meth:`set_history_buttons` (optional) |
| 2941 | You can change the history back / forward buttons to indicate disabled / enabled |
| 2942 | state. |
| 2943 | |
| 2944 | and override ``__init__`` to set up the toolbar -- without forgetting to |
| 2945 | call the base-class init. Typically, ``__init__`` needs to set up toolbar |
| 2946 | buttons connected to the `home`, `back`, `forward`, `pan`, `zoom`, and |
| 2947 | `save_figure` methods and using standard icons in the "images" subdirectory |
| 2948 | of the data path. |
| 2949 | |
| 2950 | That's it, we'll do the rest! |
| 2951 | """ |
| 2952 | |
| 2953 | # list of toolitems to add to the toolbar, format is: |
| 2954 | # ( |
| 2955 | # text, # the text of the button (often not visible to users) |
| 2956 | # tooltip_text, # the tooltip shown on hover (where possible) |
| 2957 | # image_file, # name of the image for the button (without the extension) |
| 2958 | # name_of_method, # name of the method in NavigationToolbar2 to call |
| 2959 | # ) |
| 2960 | toolitems = ( |
| 2961 | ('Home', 'Reset original view', 'home', 'home'), |
| 2962 | ('Back', 'Back to previous view', 'back', 'back'), |
| 2963 | ('Forward', 'Forward to next view', 'forward', 'forward'), |
| 2964 | (None, None, None, None), |
| 2965 | ('Pan', |
| 2966 | 'Left button pans, Right button zooms\n' |
| 2967 | 'x/y fixes axis, CTRL fixes aspect', |
| 2968 | 'move', 'pan'), |
| 2969 | ('Zoom', 'Zoom to rectangle\nx/y fixes axis', 'zoom_to_rect', 'zoom'), |
| 2970 | ('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'), |
| 2971 | (None, None, None, None), |
| 2972 | ('Save', 'Save the figure', 'filesave', 'save_figure'), |
| 2973 | ) |
| 2974 | |
| 2975 | UNKNOWN_SAVED_STATUS = object() |
| 2976 | |
| 2977 | def __init__(self, canvas): |
| 2978 | self.canvas = canvas |
no outgoing calls
searching dependent graphs…