GtkAgg Backend and Threads

We have an app that creates some background threads and is doing work at the same time it displays a pylab figure. We noticed the worker threads stopped working while we're looking at the figure and then things start working again after we close it.

Turns out, from the faq [1], you can have background threads with GtkAgg if you call gobject.threads_init().

I changed my matplotlib/backends/ to:

     import gobject
     import gtk; gdk = gtk.gdk
     import pango
except ImportError:
     raise ImportError("Gtk* backend requires pygtk to be installed.")

Sure enough, I can now have my worker threads continue in the background while we're watching the figure. I'm not sure if this should be the default behavior or if there ought to be a way to customize the backend for individual usage.

A side note however: We run the same app with a wxPython frontend sometimes. In this mode, the backend is WxAgg. The Wx backend does not have the same default behavior as the GTK backend. Our worker threads continue to do work properly with this backend. I tried PyQt with a small test app as well. It appears only GTK blocked everything so I think perhaps this change should be applied.