John Hunter wrote:
"Fernando" == Fernando Perez <Fernando.Perez@...76...> writes:
> You have to carefully wire reload() calls into the
> proper backends. It's doable, but doing it generically
> and with all the complex mpl backend machinery would
> likely take a bit of effort.
I have something in CVS that appears to work. You can interactively
switch backends in the pylab interface. The caveat is that you lose
all current figures when doing the switch (close('all') is called).
With some work I could probably patch the current figure manager to
work with multiple simultaneous backends but have no real interest in
doing this now. But it could serve as a basis for an ipython patch
that allowed you to run as ps, eg something like the following
curr = pylab.rcParams['backend']
or modify "run" to take a kwarg for the backend.
Modifying run is defitely easy. How would you like to have this done?
run -backend=BACKEND foo.py
I can't use '-d' because that's already used by %run for something else. Or we can have a different run altogether
runb BACKEND foo.py
which would be specific to backend switching, modeled on your runps() above.
Please note that I'll only add this if you really see it as an issue, I brought it up mostly for discussion, because I'm just getting my bearings around mpl. If you feel it's best to leave things as they are, I'll go along.
> But for now, I'd rather see the tk close bug fixed and
> the figure() improvements I referred to in my other mail
Well, the tk close bug should be a non-issue with CVS matplotlib.
Just make sure you use the rc param (which is the default in CVS)
tk.pythoninspect : False # tk sets PYTHONINSEPCT
Sorry, but no. I just updated CVS (and I did get my new patch, so it seems to be pretty up to date), set this variable in my .matplolibrc, and I still get this:
In : run tkbug.py
*** I'm about to close figure 1, this will crash VTK!!! ***
Generic Warning: In /usr/local/installers/src/vtk/VTK/Rendering/vtkTkRenderWidget.cxx, line 633
A TkRenderWidget is being destroyed before it associated vtkRenderWindow is destroyed. This is very bad and usually due to the order in which objects are being destroyed. Always destroy the vtkRenderWindow before destroying the user interface components.
So the Tk window destruction bug remains... Let me know if you make updates, I'll gladly test. Or if you have TkAgg/Mayavi, this is again the simple test case for reference:
planck[pylab]> cat tkbug.py
# This script crashes vtk, when run in an ipython -pylab session, with TkAgg
# as the default backend.
# The key is that the pylab.plot() call is made BEFORE the imv.surf call. If
# I call imv.surf() first, it works fine. Something in matplotlib is
# destroying windows it shouldn't.
from matplotlib import pylab
from mayavi.tools import imv
x= y = pylab.arange(256)
print "*** I'm about to close figure 1, this will crash VTK!!! *** \n"
And your figure num patch is already in....
I saw that, great. Many thanks, I really like it better this way.