I've been trying to use matplotlib from boa constructor (on windows,
running enthon-python2.4-1.0.0 and boa-constructor 0.4.4). For test
purpose I have a single button-event call this function:
Everything is fine for the first event - button fires the function and
a plot-window is showing. Killing this window and have a second go at
the plot at first seems to work but the window can not be closed and
when I try to move said window the whole application crash.
There is a conflict between the GUI library used by boa constructor
(wxWidgets/wxPython) and the one used by default by matplotlib when
you run the show() command (Tk).
Each of these two libraries run an event loop, handling all your
keyboard and mouse inputs. When you start your application, wxWidgets
has control. When you run show(), Tk takes control and displays your
matplotlib chart. But when you close the chart window, Tk keeps
control, so your application freezes.
The solution is to use another backend, compatible with wxpython. Try
backend WX or WXAgg.
At the top of your script (before import pylab), add this:
More explanations here: http://matplotlib.sourceforge.net/backends.html
For reference, here is information provided on matplotlib's web site:
There are known conflicts with some of the backends with some python
IDEs such as pycrust, idle. If you want to use matplotlib from an IDE,
please consult backends for compatibility information. You will have
the greatest likelihood of success if you run the examples from the
command shell or by double clicking on them, rather than from an IDE.
If you are interactively generating plots, your best bet is TkAgg from
the standard python shell or ipython.
-- Nicolas Grilly