i have matplotlib already installed on my machine and i use it
regularly
but when a try to add it to a controller the application crash
here is the controller (actually is an example of use matplotlib with
tg1)
import StringIO
import matplotlib
import numpy
from matplotlib.backends.backend_agg import FigureCanvasAgg
class RootController(BaseController):
def expose_matplot_figure(f=None, **render_opts):
def get_fig(result):
if isinstance(result, dict):
fig = result['fig']
del result['fig']
return fig
else:
return result
def get_render_opts(result):
if isinstance(result, dict):
render_opts.update(result)
return render_opts
def wrap_f_with_render_figure(f):
def render_figure(*pargs, **vargs):
# Make the PNG
result = f(*pargs, **vargs)
canvas = FigureCanvasAgg(get_fig(result))
rendered_fig = StringIO.StringIO()
canvas.print_figure(rendered_fig,
**get_render_opts(result))
return rendered_fig.getvalue()
return expose(content_type="image/png")(render_figure)
if f is None:
# This corresponds to the usage
@expose_matplotlib_figure(dpi=20)
return wrap_f_with_render_figure
else:
# This corresponds to the usage
@expose_matplotlib_figure
return wrap_f_with_render_figure(f)
i guess the traceback don't add any useful information but if it is
useful i will post it
I guess the tg2env lacks of that package so I try with easy_install
matplotlib inside the tg2env but it doesn't work
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---