By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,997 Members | 1,470 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,997 IT Pros & Developers. It's quick & easy.

tkinter gnuplot

P: n/a
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
Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Fernando Perez wrote:
Rama Calaga wrote:
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.


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
Jul 18 '05 #2

P: n/a
Rama Calaga wrote:
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
Jul 18 '05 #3

P: n/a
Em Qua, 2004-11-10 às 15:31 -0700, Fernando Perez escreveu:
Rama Calaga wrote:
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 gnuplotfrom
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
Jul 18 '05 #4

P: n/a
Fábio Mendes wrote:
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

Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.