Hi, I read many doco/posts already but still have trouble. I use TG2.1
on Py2.5, WinXP.
I am able to display .png (and .svg thanx Percious) by return string
from controller. But how to make it display in the page? I know I
must use template @expose('some.template') and pass eg. dict
(class_id=, data= etc.) but should I use the the ${genshi_var), the
py:content or the XML(content)?
with template like this
<div id="matplot" style="width: 720px; height: 480px;">
<img src="${tmpl_context.filename}" width="720" height="480" /
>
</div>
</body>
controller like this
from sample_fig import fig #a matplot figure
@expose(content_type="image/png")
def mat_plot_str(self, fig=fig):
#from matplotlib.backends.backend_agg import FigureCanvasAgg
canvas = FigureCanvasAgg(fig)
imgStr = StringIO.StringIO() #<=> rendered_fig
canvas.print_figure(imgStr)
return imgStr.getvalue() #It works!
Now, how to make it show inside the same page?
Thanks in advance
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---