Bypass keyboard navigation

Hello!

My name is David Mashburn, and I have been a very happy user of
matplotlib for almost 5 years now, so let me start by saying thank you
for this wonderful piece of software! I has been a blessing to me!

I am creating a program that performs actions based on key commands in
matplotlib, and I keep bumping into conflicts with the interactive
keyboard navigation system. Is there any way to bypass or disable some
or all of the keybindings hooked to interactive navigation?

By the way, I'm using the WxAgg backend if that matters.

Thanks!
-David

David,

I have not tested this myself, but I believe that if you set “navigate=False” as a keyword argument for making your axes, this will stop the callbacks from being registered.

Thanks for using matplotlib!

Ben Root

···

On Mon, Jul 26, 2010 at 3:09 PM, David Mashburn <david.n.mashburn@…287…> wrote:

Hello!

My name is David Mashburn, and I have been a very happy user of

matplotlib for almost 5 years now, so let me start by saying thank you

for this wonderful piece of software! I has been a blessing to me!

I am creating a program that performs actions based on key commands in

matplotlib, and I keep bumping into conflicts with the interactive

keyboard navigation system. Is there any way to bypass or disable some

or all of the keybindings hooked to interactive navigation?

By the way, I’m using the WxAgg backend if that matters.

Thanks!

-David

    Hello!

    My name is David Mashburn, and I have been a very happy user of
    matplotlib for almost 5 years now, so let me start by saying thank you
    for this wonderful piece of software! I has been a blessing to me!

    I am creating a program that performs actions based on key commands in
    matplotlib, and I keep bumping into conflicts with the interactive
    keyboard navigation system. Is there any way to bypass or disable some
    or all of the keybindings hooked to interactive navigation?

    By the way, I'm using the WxAgg backend if that matters.

    Thanks!
    -David

David,

I have not tested this myself, but I believe that if you set
"navigate=False" as a keyword argument for making your axes, this will
stop the callbacks from being registered.

That completely disables the toolbar, which is likely not what the OP wants.

There are a bunch of rcParams, listed at the bottom of matplotlibrc_template (and of the default matplotlibrc file that is installed) that can be used to turn off the key bindings without disabling the toolbar.

Personally, I think that putting in all those key bindings by default was a major mistake, one that should be reversed ASAP. Having the plot jump to fullscreen when one bumps "f" is rude. The first time it happened I had no idea what was going on or how to recover from it--I thought maybe my X-server had gone bonkers. And does one actually save a displayed figure so often that it is useful to have the "s" shortcut to save one from having to click the toolbar button? I could go on with this complaint...

Eric

···

On 07/26/2010 10:18 AM, Benjamin Root wrote:

On Mon, Jul 26, 2010 at 3:09 PM, David Mashburn > <david.n.mashburn@...287... <mailto:david.n.mashburn@…287…>> wrote:

Thanks for using matplotlib!

Ben Root

Ben and Eric,

Thanks so much for your help!

I'm trying to turn change some of the rcParams in my script... Here is a test of what happens:

import matplotlib
matplotlib.rcParams['keymap.fullscreen']=''

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/usr/lib/pymodules/python2.6/matplotlib/__init__.py", line 623, in __setitem__
    See rcParams.keys() for a list of valid parameters.'%key)
KeyError: 'keymap.fullscreen is not a valid rc parameter.See rcParams.keys() for a list of valid parameters.'

It seems that none of the keymap parameters are defined in my rcParams dictionary...

I also tried adding some of the "keymap" lines out of the online rc file:
http://matplotlib.sf.net/_static/matplotlibrc
to my rc file and it told me: Bad key "keymap.pan"

I've got version 0.99.0 on ubuntu.

Is this a new feature? Do you know what I can try instead??

Thanks!
-David

    Hello!

    My name is David Mashburn, and I have been a very happy user of
    matplotlib for almost 5 years now, so let me start by saying thank you
    for this wonderful piece of software! I has been a blessing to me!

    I am creating a program that performs actions based on key commands in
    matplotlib, and I keep bumping into conflicts with the interactive
    keyboard navigation system. Is there any way to bypass or disable some
    or all of the keybindings hooked to interactive navigation?

    By the way, I'm using the WxAgg backend if that matters.

    Thanks!
    -David

David,

I have not tested this myself, but I believe that if you set
"navigate=False" as a keyword argument for making your axes, this will
stop the callbacks from being registered.

That completely disables the toolbar, which is likely not what the OP wants.

There are a bunch of rcParams, listed at the bottom of matplotlibrc_template (and of the default matplotlibrc file that is installed) that can be used to turn off the key bindings without disabling the toolbar.

Personally, I think that putting in all those key bindings by default was a major mistake, one that should be reversed ASAP. Having the plot jump to fullscreen when one bumps "f" is rude. The first time it happened I had no idea what was going on or how to recover from it--I thought maybe my X-server had gone bonkers. And does one actually save a displayed figure so often that it is useful to have the "s" shortcut to save one from having to click the toolbar button? I could go on with this complaint...

Eric

···

On 07/26/2010 10:18 AM, Benjamin Root wrote:

On Mon, Jul 26, 2010 at 3:09 PM, David Mashburn > <david.n.mashburn@...287... <mailto:david.n.mashburn@…287…> <mailto:david.n.mashburn@…287…>> wrote:

Thanks for using matplotlib!

Ben Root

Ben and Eric,

Thanks so much for your help!

I'm trying to turn change some of the rcParams in my script... Here is a
test of what happens:

import matplotlib
matplotlib.rcParams['keymap.fullscreen']=''

Traceback (most recent call last):
   File "<input>", line 1, in<module>
   File "/usr/lib/pymodules/python2.6/matplotlib/__init__.py", line 623,
in __setitem__
     See rcParams.keys() for a list of valid parameters.'%key)
KeyError: 'keymap.fullscreen is not a valid rc parameter.See
rcParams.keys() for a list of valid parameters.'

It seems that none of the keymap parameters are defined in my rcParams
dictionary...

I also tried adding some of the "keymap" lines out of the online rc file:
http://matplotlib.sf.net/_static/matplotlibrc
to my rc file and it told me: Bad key "keymap.pan"

I've got version 0.99.0 on ubuntu.

Aha! I thought you were using 1.0. For 1.0, these things are rc settings; I had no idea they even existed back in 0.99.0. I only tripped over "f" very recently.

The key bindings are coded in the key_press() method of FigureManagerBase. The callback is connected to the canvas in the __init__ method. The trick is to disconnect the callback:

fig = figure()
fig.canvas.mpl_disconnect(3)
plot([1,2,3])

Now key presses have no effect in that figure. The bad thing here is that I used the cid 3, a seemingly random number. I suspect, though, that once you find out what it is in your version of mpl (and it may still be 3), you will be able to rely on it for your purposes. To find it, print out fig.canvas.callbacks.callbacks and look for key_press_event. You could have your program use this dictionary to look it up.

Eric

···

On 07/26/2010 12:17 PM, David Mashburn wrote:

Is this a new feature? Do you know what I can try instead??

Thanks!
-David

On 07/26/2010 10:18 AM, Benjamin Root wrote:

On Mon, Jul 26, 2010 at 3:09 PM, David Mashburn >> <david.n.mashburn@...287...<mailto:david.n.mashburn@…287…> <mailto:david.n.mashburn@…287…>> wrote:

     Hello!

     My name is David Mashburn, and I have been a very happy user of
     matplotlib for almost 5 years now, so let me start by saying thank you
     for this wonderful piece of software! I has been a blessing to me!

     I am creating a program that performs actions based on key commands in
     matplotlib, and I keep bumping into conflicts with the interactive
     keyboard navigation system. Is there any way to bypass or disable some
     or all of the keybindings hooked to interactive navigation?

     By the way, I'm using the WxAgg backend if that matters.

     Thanks!
     -David

David,

I have not tested this myself, but I believe that if you set
"navigate=False" as a keyword argument for making your axes, this will
stop the callbacks from being registered.

That completely disables the toolbar, which is likely not what the OP wants.

There are a bunch of rcParams, listed at the bottom of
matplotlibrc_template (and of the default matplotlibrc file that is
installed) that can be used to turn off the key bindings without
disabling the toolbar.

Personally, I think that putting in all those key bindings by default
was a major mistake, one that should be reversed ASAP. Having the plot
jump to fullscreen when one bumps "f" is rude. The first time it
happened I had no idea what was going on or how to recover from it--I
thought maybe my X-server had gone bonkers. And does one actually save a
displayed figure so often that it is useful to have the "s" shortcut to
save one from having to click the toolbar button? I could go on with
this complaint...

Eric

Thanks for using matplotlib!

Ben Root

------------------------------------------------------------------------------
The Palm PDK Hot Apps Program offers developers who use the
Plug-In Development Kit to bring their C/C++ apps to Palm for a share
of $1 Million in cash or HP Products. Visit us here for more details:
http://ad.doubleclick.net/clk;226879339;13503038;l?
http://clk.atdmt.com/CRS/go/247765532/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options