Here's an updated patch:

I decided to go with 'c' and 'v'  for Back and Forward since these keys
are in the same place on most localized keyboard layouts (sorry, dvorak
users) (as JDH pointed out, I could not use 'z' and 'x' because 'x' is
used as a modifier in Pan/Zoom mode)

I've added a ReST table detailing all of the key bindings as per JDH's
suggestion.

I included 'g' and 'l' for toggling grid and y scale under the heading
of "In axes only" though there's probably a better way of saying that.

Not sure if those belong there, but they seem to have not been
documented elsewhere ( same with 'f' for fullscreen)

navigation_toolbar.rst compiled and looked fine with rst2html.py and
rst2newlatex.py. The bullets ('- ') created extra vertical whitespace in
the table when I ran latex on the rst2latex.py output. If that's a
problem, those can be replaced with '-- '

looking forward to your feedback,
Paul Ivanov

John Hunter, on 2008-10-17 04:02, wrote:
> On Thu, Oct 16, 2008 at 9:18 PM, Paul Ivanov <[EMAIL PROTECTED]> wrote:
>> Hi,
>>
>> I'm a big fan of keyboard shortcuts, so I decided to add these guys to
>> lib/matplotlib/backend_bases.py
>>
>> I'm not sure if this is too much, and maybe these should be configurable
>> down the line, but here's my first stab at it, what do you all think?
>>
>> in the same order as they appear in the toolbar:
>> 'h' or 'r' for Home/Reset
>> left arrow or 'z' or backspace for Back
>> right arrow and 'x' for Forward
>> 'p' for pan axes with right, zoom with left mode toggle
>> 'o' for z*o*om to rectangle mode toggle
>> 's' for save
> 
>> 'z' and 'x' I borrowed from the Opera browser, very handy to for
>> righties who can have their left hand on the keyboard while using the mouse.
> 
> Hi Paul,
> 
> I'm amenable to additional keys, but check out
> http://matplotlib.sourceforge.net/users/navigation_toolbar.html which
> details which keys are already in play.  Also, with your patch, please
> submit a patch against the navigation toolbar doc
> doc/users/navigation_toolbar.rst . Maybe a ReST table that details all
> of the key bindings?
> 
> Thanks,
> JDH

Index: doc/users/navigation_toolbar.rst
===================================================================
--- doc/users/navigation_toolbar.rst	(revision 6289)
+++ doc/users/navigation_toolbar.rst	(working copy)
@@ -76,6 +76,30 @@
     ``svg`` and ``pdf``.
 
 
+Navigation Keyboard Shortcuts
+-----------------------------
+
+================================== =====================
+Command                            Keyboard Shortcut(s)
+================================== =====================
+Home/Reset                         **h** or **r** or **home**
+Back                               **c** or **left arrow** or **backspace**
+Forward                            **v** or **right arrow** 
+Pan/Zoom                           **p**                                        
+Zoom-to-rect                       **o**                   
+Save                               **s**                   
+Toggle fullscreen                  **f**
+---------------------------------- ---------------------
+**Pan/Zoom mode only**             
+- constrain pan/zoom to x axis     hold **x**
+- constrain pan/zoom to y axis     hold **y**
+- preserve aspect ratio            hold **CONTROL**     
+---------------------------------- ---------------------
+**In axes only**
+- Toggle grid                      **g**
+- Toggle y axis scale (log/linear) **l**
+================================== =====================
+
 If you are using :mod:`matplotlib.pyplot` the toolbar will be created
 automatically for every figure.  If you are writing your own user
 interface code, you can add the toolbar as a widget.  The exact syntax
Index: lib/matplotlib/backend_bases.py
===================================================================
--- lib/matplotlib/backend_bases.py	(revision 6289)
+++ lib/matplotlib/backend_bases.py	(working copy)
@@ -1513,6 +1513,23 @@
 
         if event.key == 'f':
             self.full_screen_toggle()
+        
+        # *h*ome or *r*eset mnemonic
+        elif event.key == 'h' or event.key == 'r' or event.key == "home":
+            self.canvas.toolbar.home()
+        # c and v to enable left handed quick navigation
+        elif event.key == 'left' or event.key == 'c' or event.key == 'backspace':
+            self.canvas.toolbar.back()
+        elif event.key == 'right' or event.key == 'v':
+            self.canvas.toolbar.forward()
+        # *p*an mnemonic
+        elif event.key == 'p':
+            self.canvas.toolbar.pan()
+        # z*o*om mnemonic
+        elif event.key == 'o':
+            self.canvas.toolbar.zoom()
+        elif event.key == 's':
+            self.canvas.toolbar.save_figure(self.canvas.toolbar)
 
         if event.inaxes is None:
             return
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to