embedded python and matplotlib

I am a newbie to python, numpy, and matplotlib, and I like what I have seen so far. I have been wishing for a long time there was an open alternative to matlab, and when I heard about numpy and matplotlib, I tried them out immediately.

Anyway, I am running python embedded in a C++ WX app. I just discovered matplotlib, so I tried it out. From the interactive python shell (vanilla FC5 linux install of python and matplotlib) everything works fine. The show() command blocks.

In my application, I use the PyRun_SimpleFile command to execute user selected python files on a separate thread. That has seemed to work fine for several weeks on scripts using numpy and such. When I use matplotlib, however, the show() command does not block, and then strange things happen when I try to close the Figure window. On the first close it reopens the window right back up. On the second close attempt it closes (gdb splits out zombie thread messages), and then if I try to execute another script with a show() command in it it sometimes seg faults, sometimes works, but in general causes my program to behave strangely.

So my question is: what is the correct way to setup python and/or matplotlib when running python embedded? Is there a way to make show() blocking when using embedded python (I am not sure this will solve any problems).

Thanks,
Lane Brooks

Hi Lane,

I don't have any answers for you here, but I do wonder if you might
gains some insight on this by looking at the way IPython handles its
'-pylab' and '-gthread' etc flags?

Cheers
JP

Lane Brooks wrote:

···

So my question is: what is the correct way to setup python and/or
matplotlib when running python embedded? Is there a way to make show()
blocking when using embedded python (I am not sure this will solve any
problems).

Thanks,
Lane Brooks

I found that using any of the non-GTK backends--like QTAgg or WXAgg--caused show() to block and at stopped the thread issues. I am not sure the implications of this, but it works for now. So I am content at least for the moment.

Thanks,
Lane

John Pye wrote:

···

Hi Lane,

I don't have any answers for you here, but I do wonder if you might
gains some insight on this by looking at the way IPython handles its
'-pylab' and '-gthread' etc flags?

Cheers
JP

Lane Brooks wrote:

So my question is: what is the correct way to setup python and/or matplotlib when running python embedded? Is there a way to make show() blocking when using embedded python (I am not sure this will solve any problems).

Thanks,
Lane Brooks