tkinter gnuplot

Fernando Perez fperez528 at yahoo.com
Wed Nov 10 23:39:09 CET 2004


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



More information about the Python-list mailing list