Home > GSOC2015, kivy, matplotlib > Navigation Toolbar with matplotlib events connected

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)

Navigation Toolbar Kivy

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.

Advertisements
Categories: GSOC2015, kivy, matplotlib Tags: , ,
  1. No comments yet.
  1. August 26, 2015 at 2:08 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: