tkinter gnuplot

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rama Calaga

    #1

    tkinter gnuplot

    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


  • Fernando Perez

    #2
    Re: tkinter gnuplot

    Fernando Perez wrote:
    [color=blue]
    > Rama Calaga wrote:
    >[color=green]
    >> 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 ??[/color]
    >
    > 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.[/color]

    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

    Comment

    • Fernando Perez

      #3
      Re: tkinter gnuplot

      Rama Calaga wrote:
      [color=blue]
      > 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 ??[/color]

      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

      Comment

      • Fábio Mendes

        #4
        Re: tkinter gnuplot

        Em Qua, 2004-11-10 às 15:31 -0700, Fernando Perez escreveu:[color=blue]
        > Rama Calaga wrote:
        > [color=green]
        > > 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 ??[/color]
        >
        > 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,
        > [/color]
        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

        Comment

        • Fernando Perez

          #5
          Re: tkinter gnuplot

          Fábio Mendes wrote:
          [color=blue]
          > 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.[/color]

          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

          Comment

          Working...