On Fri, Jul 18, 2008 at 10:14:00AM -0500, John Hunter wrote: > Basically, you want to support users who are using ipython -wthread > but not -pylab who later import pylab with a misconfigured rc.
That's ine way of putting it. You are considering the ipython, the way it is currently implemented is the only entry point to interactiv use of matplotlib. I think the is about to change significantly with the introduction of GUI frontends to ipython, that are not inheritely bound to pylab, like 'ipython -pylab' is. In fact Enthought has very short terms plans to make an IDE. > Is this really desirable? Certainly you would want to trap this or > warn or something so they don't get strange segfaults or other hard to > diagnose errors, but automagically switching the backend in mpl may be > too helpful in the way that microsoft windows is occassionally too > helpful. You have a point. I agree that my approach is not the good one, and is forcing too mcuh magic on the user. I will elaborate what might be a better solution below. > What about checking to see if your ipython module is in sys.modules > when pyplot is imported, checking the backend, and then importing it, > checking for wthread etc, issuing a severe warning with known > misconfigurations, eg gtkagg, with instructions on how to fix is (eg > "your matplotlibrc file is here and the backend needs to be set to > such-and-such...")? This is not about the wthread option. This is about embedding in a large GUI, whether it be the IDE I was mentionning, or winpdb, or SPE, or Mayavi. I don't think the current implementation is acceptable: you are requiring the users to change the backend depending on the eventloop they are running. Not only is this tedious, but it also require a fair amount of technical knowledge and exposes details (kind of event loop) that are irrelevent to the end user. Finally a lot of people will see the crash, and simply conclude that matplotib, or the interactive program they are runnning it from is buggy. We have had this come up more than once on the enthought-dev mailing list, and I wonder how many people simply never ask. OK, now what is the way forward. We need to provide the advanced-user for a good control on the backend. We need to provide a way that simply works without changing anything. The same code should run in "ipython -pylab", idle, or SPE. I think this means we need to add an rc entry. We could have two entries for backends: backend: auto or any of the current existing backend-default: any of the current existing If backend is set to auto, pyplot would check if an event loop is running and select the appriopriate backend. If no eventloop is running, it would use the backend specified in backend-default. This should work fairly nicely. The only think I am worried about is people changing the backend using matlplotlib.use, while rc['backend'] is still at auto, and then importing pyplot, which would change again the backend. Any suggestion for how to address that? Maybe matploib.use could put a flag somewhere, saying that it has been explicitely called. Internallythe plyplot magic to choose the backend would not set this flag. Comments? Gaƫl ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-devel mailing list Matplotlib-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-devel