[Tutor] time.sleep?

Jeff Peery jeffpeery at yahoo.com
Wed Dec 1 20:31:28 CET 2004


hello I am using time.sleep(seconds) within a while loop. I don't understand the output from this loop. I pasted it below.
 
When I push the go button I would expect first that the message "monitor initiated" would appear in the text field, then another message "monitor sleeping", then a delay in time caused by sleep(), then another message "checking file size". I would also expect this to occur ten times because I have a for loop. however what happens is that nothing appears in the text field until const_checkTime*10 seconds have gone by and then all the messages appear, that is there are three different messages and ten replicates. So nothing actually appears until the for loop and sleep are finished. 
 
if I take out the for loop, no messages are executed before the time delay, the delay takes place and then all three messages appear. I would like to use a while loop and have this work continuously although nothing appears if I do this.
 
why is this happening?
thanks,Jeff
 
 
def OnGoButton(self, event):
        self.go = TRUE
        self.TextField.SetValue("Monitor Initiated\n%s" %self.TextField.GetValue())
        self.fileSize = int(stat(self.textCtrl1.GetValue())[6])
        for i in range(0,10):
            self.TextField.SetValue("Monitor Sleeping\n%s" %self.TextField.GetValue())
            time.sleep(const_checkTime)
            self.TextField.SetValue("Checking File Size\n%s" %self.TextField.GetValue())
            dummy = CheckFile(self, self.textCtrl1.GetValue(), self.fileSize)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20041201/ec282154/attachment.html


More information about the Tutor mailing list