From: Benjamin R. <ben...@ou...> - 2012-04-04 00:34:00
|
On Wed, Mar 28, 2012 at 2:36 PM, John Hunter <jd...@gm...> wrote: > > > On Wed, Mar 28, 2012 at 1:22 PM, Neal Becker <ndb...@gm...> wrote: > >> >> > import matplotlib >> > matplotlib.use('pdf') >> > >> > It looks like you are inadvertently importing the qt library in a >> headless >> > script run. >> > >> > JDH >> >> Thanks, but should that cause a (scary looking) error? Or is there a real >> problem? >> >> >> It's just a clean up error in the qt destructors I think. You are > basically in an unsupported use case: using a gui backend, but not raising > the figures with show, so our initialization code doesn't get run properly, > which means the clean up may not be properly configured. Our work is hard > enough supporting all the GUI toolkits across multiple operating systems -- > I don't know that we want to get into trying to support *unsupported* use > cases. > > JDH > > True that this is probably an unsupported use-case, but I don't see it as a totally unreasonable one. For example, in many of my scripts in one of my projects, I have command-line options to determine if I am going to save the figure to a file and another option to determine if I am going to show the figure as well. I could run these scripts with or without showing a figure. By the time I process the command-line arguments, I have already imported matplotlib. Of course, it isn't very difficult to recode it to import and select a backend according to the command-line arguments, it would be a more convoluted script that way. Note, I have not noticed any issues with this approach while using TkAgg and GTKAgg. I guess it could probably be made into a low-priority TODO item in PyQt4 to see if the destructor is being over-zealous. Neal, your best bet would be to file a wishlist item and tag it as such. Again, low priority, but maybe someone will notice something obvious at a later time. Cheers! Ben Root |