[IPython-dev] Detecting GUI mainloop running in IPython
Brian Granger
ellisonbg at gmail.com
Sun Jul 25 17:25:00 EDT 2010
On Sun, Jul 25, 2010 at 2:05 PM, Eric Firing <efiring at hawaii.edu> wrote:
> On 07/25/2010 10:56 AM, Gael Varoquaux 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 [1]: !cat /home/varoquau/.matplotlib/matplotlibrc
> > backend : GtkAgg
> >
> > In [2]: from pylab import *
> >
> > In [3]: ion()
> >
> > In [4]: plot([1,2,3])
> > Out[4]: [<matplotlib.lines.Line2D object at 0xccb4dac>]
> >
> > In [5]: from enthought.mayavi import mlab
> >
> > In [6]: mlab.test_surf()
> > Out[6]:<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
> >
> > 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.
> >
> > 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
> > poll).
>
> No, mpl is not registering an InputHook, but pygtk is. Maybe this is
> having a side effect because wx on linux is a wrapper around gtk.
>
> To get a hook registered explicitly for wx, you need to use "ipython
> --gui wx"
>
>
I should clarify. All IPython is doing in 0.11 for qt4, gtk and tk is to
tell each GUI toolkit to install its inputhook. Here is the gtk version:
http://github.com/ipython/ipython/blob/master/IPython/lib/inputhook.py#L457
Part of the difficulty is that each GUI toolkits has a different API for
doing this. We make the API uniform and add a wx inputhook using ctypes.
Cheers,
Brian
> Eric
>
> >
> > Anyhow, this is good news, eventhough I don't understand it at all.
> >
> > Gaël
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
--
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...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20100725/9f84dc63/attachment.html>
More information about the IPython-dev
mailing list