<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>problem to update gnuplot display using a Scale widget</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Hello!<BR>
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 essence have the plot refreshed by the Scale slider).<BR>
To do that, I pass the function &quot;printer(self,newval)&quot;, to the Scale's 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 write with the chevrons print statement.<BR>
<BR>
&nbsp;import os,Tkinter,string,time<BR>
&nbsp;class MyApp:<BR>
&nbsp;&nbsp;&nbsp;&nbsp; def __init__(self, parent):<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.f=os.popen(&quot;gnuplot -&quot;,&quot;w&quot;)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &gt;&gt;self.f,&quot;plot \&quot;data.dat\&quot; with lines&quot;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &gt;&gt;self.f,&quot;reread&quot;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.myParent=parent<BR>
&nbsp;self.myContainer1=Frame(parent)<BR>
&nbsp;self.myContainer1.pack()<BR>
&nbsp;self.v=DoubleVar()<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.slider1=Scale(self.myParent,from_=0,to=1,resolution=0.001,command=self.printer)#variable=self.v,command=self.printer)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.slider1.pack()<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp; def printer(self,newval):<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; os.system(&quot;/bin/generate_data_file &quot;+str(newval))<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; time.sleep(0.09)<BR>
&nbsp;print &gt;&gt;self.f,&quot;replot\n&quot;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return newval<BR>
&nbsp;root=Tk()<BR>
&nbsp;myapp=MyApp(root)<BR>
&nbsp;root.mainloop()<BR>
<BR>
&nbsp;Unfortunately I don't obtain the expected result. The Tk window is there with functioning slider, the generate_data_file is executed and given the proper input value from the slider, but gnuplot is still a problem. The gnuplot window only comes up when I close the Tkinter window, and shuts down rapidly.<BR>
Do you have any ideas as to what I need to fix ? 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 allowed).<BR>
<BR>
Thanks a lot !<BR>
<BR>
&quot;It does not pay to leave a live<BR>
dragon out of your calculations&quot;<BR>
&nbsp;- Tolkien<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>