Hi,

I'm using matplotlib in a C++ app (with a qt4 gui), by embedding python with
boost::python. The C++ app calls Py_Initialize(), init_myplottingmodule(), and
boost::python::import("matplotlib.pylab") once on startup and certain GUI
events then fire up a matplotlib window via calls like this one:

// simplified version
void plotCurve(){
    clf();
    title("Diagonal line plot");
    double O1[] = {0,1};
    plot(std::vector<double>(O1,O1+2), std::vector<double>(O1,O1+2), "b:");
    show();
}

Although this does sort of work, it doesn't work quite right. Specifically on
clicking on the close button of the window, bad things frequently happen. For
example, the first close seems to work, but subsequent attempts to close newly
opened plots just zombify the window (it no longer repaints automatically but
stays open; replots happen to that same window, i.e. the one that was opened
second).

Now I'm somewhat aware of all the nastiness of different event loops, the
heroic efforts of ipython to make matplotlib work nicely interactively without
blocking the REPL, but somehow I would have (naively) thought that all that
work was just needed to avoid blocking. For the code above, blocking till the
window would be closed is perfectly fine. Indeed that's what happens if I try
something equivalent in the plain python shell (outside the C++ app).

Any idea about the likely cause of the problem and what might be the simplest
way to get it to work as expected (similar symptoms appear w/ matplotlib
0.87.7 and 0.91 under linux and osx)?

cheers,

'as

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to