I have someone fixing the last items (status bar and error handling) from the Qt backend and I had a few questions. You said:
* If you try to save to an unsupported output type (eg pdf) the
entire window closes -- a bit extreme
This seems to happen on the TkAgg backend as well. The culprit seems to be this code (backend_tkagg.py):
except IOError, msg:
err = '\n'.join(map(str, msg))
msg = 'Failed to save %s: Error msg was\n\n%s' % (
The exception (at least for trying to save a pdf file) is not an IOError so the message get's propagated up and you exit the event loop (which is what causes the window to disappear).
I think the problem is that backend_agg.py is calling error_msg() that it COPYS from backend_bases.py. The default action from backend_bases.py is to print a message and call sys.exit() which is what is generating this message. I assume that somewhere you're trapping the exit call to send an exception?
On the surface (i.e. w/o knowing the design decisions that were made), this seems like a bad idea. It seems like exceptions should be used and that sys.exit() should exit the program. Changing the behavior of a standard call like sys.exit() (if that's what is really happening) seems like a bad idea since it changes global behavior.
Also, I'm a little confused about the backends use of the 'error_msg' function. Many of the backends import this function from backend_bases but then change that names definition to a local copy (see backend_gtk, backend_template, backend_wx). This seems wrong or at least more confusing that it needs to be. I don't think a script should explicitly import something with one name and then change the name to point to a local variable.
Is the idea that the backends should overload the error_msg function that all the code uses? If that's the case it would be a simple change to do something like this:
backend_bases.error_msg = error_msg_tkpaint
Ted Drain Jet Propulsion Laboratory ted.drain@...179...