[Tkinter-discuss] problem to update gnuplot display using aScale widget
callen at gemini.edu
Tue Sep 23 00:02:17 CEST 2008
uninvited comment: consider matplot lib, it's much better than gnuplot
imo and I say this as one that enjoyed gnuplot ease and availability
(free software) for quite some time, so no aspersions cast. But really,
consider matplotlib, I bet you would not regret it.
On Thu, 2008-09-18 at 14:14 -0500, Philippe Garteiser, PhD wrote:
> Brilliant ! Thanks that did it beautifully, my virtual kidney (renal
> function simulator) is well on its way now !
> -----Original Message-----
> From: Guilherme Polo [mailto:ggpolo at gmail.com]
> Sent: Thu 9/18/2008 12:49 PM
> To: Philippe Garteiser, PhD; tkinter-discuss at python.org
> Subject: Re: [Tkinter-discuss] problem to update gnuplot display using
> a Scale widget
> On Tue, Sep 16, 2008 at 7:19 PM, Philippe Garteiser, PhD
> <Philippe-Garteiser at omrf.org> wrote:
> > Hello!
> > I am using a Tkinter GUI to operate a C binary whose input is a
> float number
> > gotten from a Scale widget, and whose output is a datafile. I would
> like to
> > get gnuplot to replot the datafile each time it is overwritten (in
> > have the plot refreshed by the Scale slider).
> > To do that, I pass the function "printer(self,newval)", to the
> > command. In the printer function, I use os.system to execute the
> binary, and
> > I operate gnuplot as a special file opened by os.popen, to which I
> > with the chevrons print statement.
> > import os,Tkinter,string,time
> > class MyApp:
> > def __init__(self, parent):
> > self.f=os.popen("gnuplot -","w")
> > print >>self.f,"plot \"data.dat\" with lines"
> > print >>self.f,"reread"
> > self.myParent=parent
> > self.myContainer1=Frame(parent)
> > self.myContainer1.pack()
> > self.v=DoubleVar()
> > self.slider1.pack()
> > def printer(self,newval):
> > os.system("/bin/generate_data_file "+str(newval))
> > time.sleep(0.09)
> > print >>self.f,"replot\n"
> > return newval
> > root=Tk()
> > myapp=MyApp(root)
> > root.mainloop()
> > Unfortunately I don't obtain the expected result. The Tk window is
> > with functioning slider, the generate_data_file is executed and
> given the
> > proper input value from the slider, but gnuplot is still a problem.
> > gnuplot window only comes up when I close the Tkinter window, and
> shuts down
> > rapidly.
> > Do you have any ideas as to what I need to fix ?
> You are forgetting to flush f.
> Do a self.f.flush() after that "reread" and "replot".
> > Also, it would be great not
> > to have to use the pyGnuplot.py package, as the program will have to
> run on
> > minimally installed boxes (i.e. standard python, no extra modules
> > Thanks a lot !
> > "It does not pay to leave a live
> > dragon out of your calculations"
> > - Tolkien
> > _______________________________________________
> > Tkinter-discuss mailing list
> > Tkinter-discuss at python.org
> > http://mail.python.org/mailman/listinfo/tkinter-discuss
> -- Guilherme H. Polo Goncalves
> Tkinter-discuss mailing list
> Tkinter-discuss at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tkinter-discuss