First cut on a QtAgg backend

All I really interested in is seeing the QtAgg front end in

    > matplotlib as a supported component (which we'd be happy to
    > help maintain) so whatever gets us there the quickest sounds
    > good to me.

    > I am in the same position as you; I just want a Qt-backend
    > for Matplotlib.

Well, actually it looks like Ted wants a front end and Sigve wants a
backend. Let's hope these differences are not irreconcilable!


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 (

         except IOError, msg:
             err = '\n'.join(map(str, msg))
             msg = 'Failed to save %s: Error msg was\n\n%s' % (
                 fname, err)

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 is calling error_msg() that it COPYS from The default action from 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:

import backend_bases
backend_bases.error_msg = error_msg_tkpaint

Ted Drain Jet Propulsion Laboratory ted.drain@...179...