tkinter gnuplot

R

Rama Calaga

Hi, I use both python and gnuplot a lot, but I am
unable to find a way to embed gnuplot "window/canvas" into tkinter. BLT option in
PMW is not so powerful and not so great, any suggestions ??

thanks
ram
 
F

Fernando Perez

Rama said:
Hi, I use both python and gnuplot a lot, but I am
unable to find a way to embed gnuplot "window/canvas" into tkinter. BLT
option in PMW is not so powerful and not so great, any suggestions ??

I don't think there's an easy way to do that, since all access to gnuplot from
python is via a pipe. Gnuplot is an external program, not a library. You
might be able to make gnunplot generate .pngs and then load those into a tk
canvas, but it will be clumsy.

You might want to look at http://matplotlib.sourceforge.net. It's a true
python plotting library (as opposed to a pipe to an external program), set up
from the get-go for GUI embedding (with Tk, GTK and WX examples included).

Best,

f
 
F

Fernando Perez

Fernando said:
I don't think there's an easy way to do that, since all access to gnuplot
from
python is via a pipe. Gnuplot is an external program, not a library. You
might be able to make gnunplot generate .pngs and then load those into a tk
canvas, but it will be clumsy.

Mmh, Gnuplot does have a tkcanvas terminal:

This terminal driver generates Tk canvas widget commands based on Tcl/Tk
(default) or Perl. To use it, rebuild `gnuplot` (after uncommenting or
inserting the appropriate line in "term.h"), then

gnuplot> set term tkcanvas {perltk} {interactive}
gnuplot> set output 'plot.file'

After invoking "wish", execute the following sequence of Tcl/Tk commands:

% source plot.file
% canvas .c
% pack .c
% gnuplot .c

[...] See the gnuplot help for more.


So you might be able to rebuild gnuplot with this terminal, and then figure out
how to make the generated tcl/tk code accessible to tkinter. I'm not a
tkinter expert, so I have no idea how this would work.

Still, matplotlib is ready for this out of the box, so it might be less work.

Best,

f
 
?

=?ISO-8859-1?Q?F=E1bio?= Mendes

Em Qua, 2004-11-10 às 15:31 -0700, Fernando Perez escreveu:
I don't think there's an easy way to do that, since all access to gnuplot from
python is via a pipe. Gnuplot is an external program, not a library. You
might be able to make gnunplot generate .pngs and then load those into a tk
canvas, but it will be clumsy.

You might want to look at http://matplotlib.sourceforge.net. It's a true
python plotting library (as opposed to a pipe to an external program), set up
from the get-go for GUI embedding (with Tk, GTK and WX examples included)..

Best,
Or even scipy. It's a great scientific library and I think it uses
gnuplot as one of the graphical frontends (http://scipy.org) . I'm not
sure if it allows you to pass arbitrary gnuplot commands, but if you
want to build such a thing, surely the source could be helpful.

Cheers,
Fabio
 
F

Fernando Perez

Fábio Mendes said:
Or even scipy. It's a great scientific library and I think it uses
gnuplot as one of the graphical frontends (http://scipy.org) . I'm not
sure if it allows you to pass arbitrary gnuplot commands, but if you
want to build such a thing, surely the source could be helpful.

The gnuplot support in scipy is more or less deprecated, as scipy has a new
framework (Chaco) coming down the pipe, and much of today's scipy user base is
moving over to matplotlib.

For the diehard gnuplot users (a group I happen to still belong to), Gnuplot.py
offers a pretty clean interface. IPython (http://ipython.scipy.org) adds a
fair amount of functionality to make interactive gnuplot work much more
efficient, as well as simplifying some common tasks with a better syntax.

But again, the problem is that gnuplot was not meant to be embedded as a Tk
widget, which was the OP's intent. The tkcanvas terminal type is an intriguing
option, but I have no idea how hard (if it's even possible) it would be to use
that in a Python/Tkinter application.

Best,

f
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top