30/10/11 00:27, John Hunter > On Sat, Oct 29, 2011 at 2:52 PM, Antoine Levitt > <antoine.lev...@gmail.com> wrote: >> Just typing f = gcf() displays a figure, which I don't want to do. I >> want to be able to put something in my ipython init file that'd set my >> bindings, without changing anything else. > > This is a reasonable request, though there are some implementation > details to sort through. For one, the rc file format is very simple, > and not amenable to putting in multil-ine functions. But you could > write something like > > keybinding.q : lambda event: plt.close(event.canvas.figure) > > Eg, when a key is pressed for which you have associated a lambda, we > could call your lambda with the event that triggered, and you can > access attributes like canvas.figure to operate on them. We could > eval your lambda in the pyplot namespace. But more sophisticated > functions would be difficult to expose given the simplicity of rc > format.
I was thinking of ipython_config.py, which is full python. Then, add a hook for a function to be run whenever a figure is created. I don't know if I can access the matplotlib stuff from ipython_config.py though. I'll take a look. Just curious: what's the point of having a specific rc format, instead of just running python code and defining a few special functions to make it easier to write a config file? If you want to keep the rc format, why not add a command to run a python file? > > If you are interested in taking a crack at this Antoine, we'd be happy > to evaluate a pull request. If not, perhaps I or one of the other > developers can take a look. I'll take a look and report back. > > Note that in most windowing systems, it is fairly easy to bind a > keystroke to close a window, so you could get the effect of 'q' w/o > modifying MPL, though you might need a two keystroke binding, Defining "q" to mean "quit this window" for every window might be a little problematic. :-) There's always alt+f4, but I find it a little bothersome, "q" is much simpler. ------------------------------------------------------------------------------ Get your Android app more play: Bring it to the BlackBerry PlayBook in minutes. BlackBerry App World™ now supports Android™ Apps for the BlackBerry® PlayBook™. Discover just how easy and simple it is! http://p.sf.net/sfu/android-dev2dev _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel