Revision: 6175 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6175&view=rev Author: mdboom Date: 2008-10-09 11:37:01 +0000 (Thu, 09 Oct 2008)
Log Message: ----------- Better version of 'show' warning that only emits when show() is run directly from the python or ipython console. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/__init__.py Modified: trunk/matplotlib/lib/matplotlib/backends/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/__init__.py 2008-10-09 01:19:54 UTC (rev 6174) +++ trunk/matplotlib/lib/matplotlib/backends/__init__.py 2008-10-09 11:37:01 UTC (rev 6175) @@ -1,5 +1,6 @@ import matplotlib +import inspect import warnings # ipython relies on interactive_bk being defined here @@ -30,11 +31,14 @@ # for "show" or "draw_if_interactive", so if they are not defined # by the backend, just do nothing def do_nothing_show(*args, **kwargs): - warnings.warn(""" + frame = inspect.currentframe() + fname = inspect.getframeinfo(frame.f_back)[0] + if fname in ('<stdin>', '<ipython console>'): + warnings.warn(""" Your currently selected backend, '%s' does not support show(). Please select a GUI backend in your matplotlibrc file ('%s') or with matplotlib.use()""" % - (backend, matplotlib.matplotlib_fname())) + (backend, matplotlib.matplotlib_fname())) def do_nothing(*args, **kwargs): pass backend_version = getattr(backend_mod,'backend_version', 'unknown') show = getattr(backend_mod, 'show', do_nothing_show) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- 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-checkins mailing list Matplotlib-checkins@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins