[Tkinter-discuss] tkinter "monitor" and root.mainloop()

Cameron Laird Cameron at phaseit.net
Fri May 23 01:49:25 CEST 2008


On Fri, May 23, 2008 at 09:10:48AM +1000, Peter Milliken wrote:
			.
			.
			.
> in the time module, look at a function called sleep - arguments are 1 second
> intervals from memory i.e. something like this:
> 
> import time
> 
> while True:
>   <check file for changes and take appropriate action>
> 
>   time.sleep(5)          -- delay for 5 seconds before resuming loop
> 
> 
> 
> 
> On Thu, May 22, 2008 at 8:59 AM, Cameron Laird <Cameron at phaseit.net> wrote:
> 
> > On Wed, May 21, 2008 at 12:49:22PM +0200, Marco wrote:
> >                        .
> >                        .
> >                         .
> > > I am quite new to tkinter programming, and i have a question.
> > >
> > > I am writing a "monitor": basically it reads a file on the filesystem
> > > and reports it in a graphical way using python and tkinter.
> > >
> > > Now the file, over time, changes, so once called root.mainloop() i'd
> > > need to reread the file, update the objects in memory and redraw the
> > > tkinter main window.
> > >
> > > How can I achieve that? Ideas? Suggestions? Is my approach wrong?
> >                         .
> >                        .
> >                        .
> > Poll with after().  Fredrik's references, among others,
> > explain this.  I'll be tied up for a day; if you don't
> > work out the details on your own, I'll return to explain.
			.
			.
			.
Peter, while I agree that time.sleep() can serve to
construct a quick model of a polling operation, it
often leads to dissatisfaction because, in contrast
to after()-based implementations, it "freezes" the
Tkinter windows while sleep()ing.


More information about the Tkinter-discuss mailing list