[CentralOH] GUI Tools Survey
eric at intellovations.com
Wed Aug 11 15:53:31 CEST 2010
The book "Matplotlib for Python Developers" has an entire chapter on
embedding Matplotlib output (or generating it in realtime) on the web, using
a number of different frameworks:
1. CGI (via Apache's mod_cgi)
For Django (as that's what I'm familiar with) in your view code you use
matplotlib.backends.backend_agg.FigureCanvasAgg as your canvas you plot the
Figure on. Then instead of rendering a template response, you create an
HttpResponse with content_type 'image/png' (or any of the types FigureCanvas
supports) and print the bits to the response (the FigureCanvas takes a "file
like" object or a string filename, and HttpResponse is a file-like object
(i.e. has a write method)), like:
fig = Figure()
canvas = FigureCanvasAgg(fig)
... do your plot stuff ...
response = django.http.HttpResonse(content_type='image/png')
Only the last two lines are specific to the web framework, everything else
is generic plot generation that can be used in a regular GUI, etc.
So whatever URL you have defined for the image, it will return the png.
On Wed, Aug 11, 2010 at 9:26 AM, James - Atlantix <james at atlantixeng.com>wrote:
> The survey is a great idea, and hopefully will provide some very useful
> feedback. My main concern about Web based GUI's is the ability to add rich
> math content to them, such as with Matplotlib output. Has anyone any
> experience in this?
> CentralOH mailing list
> CentralOH at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the CentralOH