[IPython-dev] Detecting GUI mainloop running in IPython
ellisonbg at gmail.com
Sun Jul 25 17:28:44 EDT 2010
On Sun, Jul 25, 2010 at 1:56 PM, Gael Varoquaux <
gael.varoquaux at normalesup.org> wrote:
> On Sun, Jul 25, 2010 at 10:35:02AM -1000, Eric Firing wrote:
> > Although ipython has provided invaluable service to mpl by enabling
> > interactive plotting for all gui backends, I am not at all sure that
> > this functionality should be left to ipython in the long run. The
> > problem is that mpl is used in a variety of ways and environments. Gui
> > functionality is central to mpl; it seems odd, and unnecessarily
> > complicated, to have to delegate part of that to an environment, or
> > shell, like ipython.
> Wow, I just did a little experiment, and I really don't understand the
> outcome. Please bear with me:
> $ ipython
> In : !cat /home/varoquau/.matplotlib/matplotlibrc
> backend : GtkAgg
> In : from pylab import *
> In : ion()
> In : plot([1,2,3])
> Out: [<matplotlib.lines.Line2D object at 0xccb4dac>]
> In : from enthought.mayavi import mlab
> In : mlab.test_surf()
> Out: <enthought.mayavi.modules.surface.Surface object at 0xd58ce0c>
> Two things I do not understand:
> 1) I can interact alright with the Mayavi plot, nice and fine
> eventhough there is not wx event-loop running, and I did not
> register a InputHook
This is because pygtk automagically and by default registers a
> 2) I did not get a segfault, while I am running at the same time GTK
> and Wx. This used to be a big no no.
The reason this works is that on Linux both GTK and Wx use the same
underlying eventloop. The same is true of qt4+wx on Mac. As long as the
underlying eventloop is iterated, events from both GUI toolkits can get
handled. But this is a very OS dependent trick.
> I believe that 1 is due to matplotlib registering an InputHook, but I
> cannot find where it is done. Also, does this seems to mean that under
> Linux GTK input hooks work for Wx (and they are nicer since they don't
Yes, you are right, the gtk inputhook does work for wx on Linux. But that
requires gtk to be installed to use wx. But don't get used to this as this
type of things won't work in the two process kernel.
> Anyhow, this is good news, eventhough I don't understand it at all.
> IPython-dev mailing list
> IPython-dev at scipy.org
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgranger at calpoly.edu
ellisonbg at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev