Navigation Toolbar with matplotlib events connected
NavigationToolbar is the last visual aspect from the backend that has been added with all the possible events connected to matplotlib. The main changes performed on the implementation involved to connect each one of the toolbar elements to the respective matplotlib calls. Additionally, the figure canvas is separated from the toolbar and both are children of a Float Layout inside an app generated via pyplot. The FigureCanvasKivy can be called independently of the NavigationToolbar but not in the opposite direction.
# updated version of the toolbar generation. def _init_toolbar(self): basedir = os.path.join(rcParams['datapath'], 'images') actionview = ActionView() actionprevious = ActionPrevious(title="Navigation", with_previous=False) actionoverflow = ActionOverflow() actionview.add_widget(actionprevious) actionview.add_widget(actionoverflow) actionview.use_separator = True self.actionbar.add_widget(actionview) for text, tooltip_text, image_file, callback in self.toolitems: if text is None: actionview.add_widget(ActionSeparator()) continue fname = os.path.join(basedir, image_file + '.png') if text in ['Pan', 'Zoom']: action_button = ActionToggleButton(text=text, icon=fname) else: action_button = ActionButton(text=text, icon=fname) action_button.bind(on_press=getattr(self, callback)) actionview.add_widget(action_button)
For matplotlib users the interface can look very familiar. However, I consider a brief explanation is necessary on the function of each button:
- Home: Resets the plot axes to the initial state.
- Left: Undo an operation performed.
- Right: Redo an operation performed.
- Pan: Allows to drag the plot.
- Zoom: Allows to define a rectangular area to zoom in.
- Configure: Not implemented yet but, loads a pop up for repositioning elements.
- Save: Loads a Save Dialog to generate an image.
Configure and Save will be added at some point the next week.