title: Toggling button state on matplotlib NavigationToolbar programmatically
body: <p>I am embedding a figure with a customized <code>NavigationToolbar2WxAgg</code> so that I can (hopefully) easily control the state of the toolbar.  I would like to be able to toggle the zoom and pan buttons, but I'm having some difficulty getting it to work properly.  My code for the toolbar is</p>
  
  <pre class="lang-py prettyprint-override"><code>class CustomNavToolbar(NavigationToolbar2WxAgg):
      def __init__(self, *args, **kwargs):
          NavigationToolbar2WxAgg.__init__(self, *args, **kwargs)
  
          self.DeleteToolByPos(7)  # Deletes the adjust subplots button
  
      @property
      def IsActive(self):
          return self._active is not None
  
      def DeactivateAll(self):
          if self._active == 'PAN':
              self.pan('off')
          elif self._active == 'ZOOM':
              self.zoom()
  </code></pre>
  
  <p>with the idea that I can just call <code>DeactivateAll()</code> method to turn off any mode that is currently active.  Unfortunately, this doesn't work quite right.  The mode is disabled, but the button itself stays toggled.  And when I click the button again, the mode is enabled, but the button is untoggled.</p>
  
  <p>My google-fu couldn't come up with a working solution, can someone point me towards the right method?</p>