Fwd: [IPython-dev] GUI support: conflicts between IPython 0.11 and Matplotlib/ETS

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Fwd: [IPython-dev] GUI support: conflicts between IPython 0.11 and Matplotlib/ETS

Fernando Perez
Hi folks,

the message below is an important discussion on which we'd like
feedback/ideas both from Enthought.traits experts and matplotlib ones.
 It would be great if we could keep things in one list, so it seems
most sensible to hold the discussion in the ipython-dev list, but this
is a heads-up in case one of you is interested but may not monitor



---------- Forwarded message ----------
From: Brian Granger <[hidden email]>
Date: Tue, Feb 9, 2010 at 11:59 PM
Subject: [IPython-dev] GUI support: conflicts between IPython 0.11 and
To: IPython Development list <[hidden email]>

Hello all,

As many of you know, we have been working hard on IPython 0.11.  One
of the big new features of 0.11 is a refactored integration with GUI
event loops.
We are very excited about this as it is much more stable and add new
capabilities, like being able to enable pylab *after* starting IPython
(it is a magic: %pylab).

BUT, as Fernando and I have started to use the IPython 0.11 alpha for
our daily work, we have found some subtle issue with IPython 0.11 and
the current
versions of matplotlib and Enthought tool suite (traits, chaco,
mayavi).  All of these packages rely on IPython's previous way of
handling GUI
integration.  Because of this, current versions of matplotlib and ets
don't work fully with IPython 0.11.  In some cases, they work OK, but
there are a whole class
of bugs that keep popping up.  We don't want to release IPython 0.11
until these issues are resolved.

All of these bugs are related to a few aspects of creating the main
GUI app objects and starting event loops.  We think we understand the
issues, but we will
need to work with the devs of matplotlib and ets to decide on how we
all want to handle these things.  Here is where we are at...

Current situation

Both matplotlib and ets have code that tries to:

* See what GUI toolkit is being used
* Get the global App object if it already exists, if not create it.
* See if the main loop is running, if not possibly start it.

All of this logic makes many assumptions about how IPython affects the
answers to these
questions.  Because IPython's GUI support has changed in significant
ways, current matplotlib
and ets make incorrect decisions about these issues (such as trying to
start the event loop
a second time, creating a second main App ojbect, etc.) under IPython
0.11.  This leads to crashes...

Description of GUI support in 0.11

IPython allows GUI event loops to be run in an interactive IPython session.
This is done using Python's PyOS_InputHook hook which Python calls
when the :func:`raw_input` function is called and is waiting for user input.
IPython has versions of this hook for wx, pyqt4 and pygtk.  When the inputhook
is called, it iterates the GUI event loop until a user starts to type
again.  When
the user stops typing, the event loop iterates again.  This is how tk works.

When a GUI program is used interactively within IPython, the event loop of
the GUI should *not* be started. This is because, the PyOS_Inputhook itself
is responsible for iterating the GUI event loop.

IPython has facilities for installing the needed input hook for each GUI
toolkit and for creating the needed main GUI application object. Usually,
these main application objects should be created only once and for some
GUI toolkits, special options have to be passed to the application object
to enable it to function properly in IPython.

What we need to decide

We need to answer the following questions:

* Who is responsible for creating the main GUI application object, IPython
  or third parties (matplotlib, enthought.traits, etc.)?

* What is the proper way for third party code to detect if a GUI application
  object has already been created?  If one has been created, how should
  the existing instance be retrieved?

* In a GUI application object has been created, how should third party code
  detect if the GUI event loop is running. It is not sufficient to call the
  relevant function methods in the GUI toolkits (like ``IsMainLoopRunning``)
  because those don't know if the GUI event loop is running through the
  input hook.

* We might need a way for third party code to determine if it is running
  in IPython or not.  Currently, the only way of running GUI code in IPython
  is by using the input hook, but eventually, GUI based versions of IPython
  will allow the GUI event loop in the more traditional manner. We will need
  a way for third party code to distinguish between these two cases.

Thanks for participating in this discussion!



IPython-dev mailing list
[hidden email]
Enthought-Dev mailing list
[hidden email]