loop problem

Paul Boots bootsch at acm.org
Wed Jul 13 17:07:12 EDT 2005


Hi,

First ;-) I don't know Tk or plot, but from looking at your code I see you want to plot
a line a minute long, after that, all dots are drawn to the screen. You call

>                self.graph.addSet(x,y)

My guess is that you have to explicitly draw to the screen using same call from
graph or self? whatever Tkinter wants. Search the tkinter/tk docs for 'draw'
calls.



At 16:18 -0400 13/7/2005, Shankar Iyer (siyer at Princeton.EDU) wrote:
>Content-Language: en
>Content-Type: text/html; charset=us-ascii
>Content-Disposition: inline
>Content-Transfer-Encoding: 7bit
>
>Hi,
>
>     First, I want to thank those who responded to my question about "the plot module" yesterday.  I realize now that the question could have been vague.  There is a plot module, simply called "plot," that I am using, and I guess it is not a very widely circulated plotting utility.
>
>    Anyway, I'm a little confused by the output that I get from the following code:
>
>/*******************************************************************************************************/
>
>from Tkinter import *
>from tkSimpleDialog import *
>import Pmw
>import HP34401A
>import plot
>import time
>
>class Application(Frame):
>
>    def __init__(self,master=None):
>        Frame.__init__(self,master)
>        self.pack()
>        self.graph = plot.plot(self)
>        self.beginplotting()
>
>    def beginplotting(self):
>        x = []
>        y = []
>        i = 0
>        fLastOutput = time.time()
>        while 1:
>            fTime = time.time()
>            if((fTime-fLastOutput) >= 2):
>                i += 1
>                x.append(fTime)
>                y.append(2*fTime)
>                self.graph.addSet(x,y)
>                fLastOutput = fTime
>                if(i>=30):break
>
>app = Application()
>app.mainloop()
>
>/*******************************************************************************************************/
>
>This is supposed to plot a point every two seconds.  When it actually runs, it instead stores all the data points and then plots them after 30 data points have been taken.  I'm fairly certain that this is not due to the use of the plot class.  If I have the program instead write each time into a Tkinter Text widget, the same type of thing happens.  That is, the program stores all 30 times in memory and then dumps them into the Text widget at the end.  Since I have written the code so that it plots (or writes to the Text widget) every two seconds, I am confused as to why this is happening.
>
>Shankar
>
>
>--
>http://mail.python.org/mailman/listinfo/python-list


-- 
Vriendelijke groet,
Paul



More information about the Python-list mailing list