patch to close plots with 'q'

Hello, first time poster,

I’ve made a patch to add a keyboard shortcut to close plot windows with the ‘q’ key (patchfile attached, in case it is of interest to the matplotlib team). But as I was finishing it up, I noticed that there was already something similar in the code, commented out (even using the same key!):

#if event.key == ‘q’:

self.destroy() # how cruel to have to destroy oneself!

return

I didn’t implement it this way (I used self.close() and tried to emulate the other key commands), but I wondered if this was an indication that adding a keyboard shortcut for close() was a bad idea for any reason.

Also, is it possible to a custom keyboard shortcut for particular backends? For example, I’d like for “command-w” to close plotting windows for the mac os x backend. Would this be added to backend_macosx.py?

Finally, I noticed that on OS X, the plots used to be the active window once they were created (1.0.0, possibly earlier), but now they appear behind my terminal window when created (1.0.1). Is this a setting in backend_macosx.py, or somewhere else?

Thanks for your time, and the wonderful plotting library,

Marshall

mlw.patch (1.5 KB)

Hello, first time poster,

I've made a patch to add a keyboard shortcut to close plot windows with
the 'q' key (patchfile attached, in case it is of interest to the
matplotlib team). But as I was finishing it up, I noticed that there was
already something similar in the code, commented out (even using the
same key!):

         #if event.key == 'q':
         # self.destroy() # how cruel to have to destroy oneself!
         # return

I didn't implement it this way (I used self.close() and tried to emulate
the other key commands), but I wondered if this was an indication that
adding a keyboard shortcut for close() was a bad idea for any reason.

In my opinion, having it enabled by default is a horrible idea--it is too easy to hit it accidentally, and when one does so, the consequence is too damaging. The present default-enabled shortcuts are bad enough; I am tempted to change the defaults--but maybe more people would be displeased than pleased by that change.

Also, is it possible to a custom keyboard shortcut for particular
backends? For example, I'd like for "command-w" to close plotting
windows for the mac os x backend. Would this be added to backend_macosx.py?

My dim recollection is that we don't presently have support for anything other than the normal keys. I don't know what is involved in adding it.

I hope Michiel de Hoon can reply regarding backend_macosx specifics.

Finally, I noticed that on OS X, the plots used to be the active window
once they were created (1.0.0, possibly earlier), but now they appear
behind my terminal window when created (1.0.1). Is this a setting in
backend_macosx.py, or somewhere else?

I'm pretty sure that if it is within mpl, it would be in backend_macosx. It is not the sort of thing I would expect to have changed, though. Again, Michiel de Hoon may be able to shed light on this.

Eric

···

On 02/09/2011 09:23 PM, Marshall Ward wrote:

Thanks for your time, and the wonderful plotting library,
Marshall

Hello, first time poster,

Marshall,

Welcome! I'm sorry my first reply was a bit curt, especially considering that you are offering a patch. We do appreciate contributions. A little discussion may be required as to the future strategy for keyboard shortcuts, but thank you for getting started.

Eric

···

On 02/09/2011 09:23 PM, Marshall Ward wrote:

I've made a patch to add a keyboard shortcut to close plot windows with
the 'q' key (patchfile attached, in case it is of interest to the
matplotlib team). But as I was finishing it up, I noticed that there was
already something similar in the code, commented out (even using the
same key!):

         #if event.key == 'q':
         # self.destroy() # how cruel to have to destroy oneself!
         # return

I didn't implement it this way (I used self.close() and tried to emulate
the other key commands), but I wondered if this was an indication that
adding a keyboard shortcut for close() was a bad idea for any reason.

Also, is it possible to a custom keyboard shortcut for particular
backends? For example, I'd like for "command-w" to close plotting
windows for the mac os x backend. Would this be added to backend_macosx.py?

Finally, I noticed that on OS X, the plots used to be the active window
once they were created (1.0.0, possibly earlier), but now they appear
behind my terminal window when created (1.0.1). Is this a setting in
backend_macosx.py, or somewhere else?

Thanks for your time, and the wonderful plotting library,
Marshall

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options