Okay I got a question regarding Tkinter and Labels

Fredrik Lundh fredrik at pythonware.com
Sun Jan 20 07:43:56 EST 2008


Lamonte Harris wrote:

> Okay I've created a script and basically when I loop through a folder it 
> is supposed to change the Label everytime it updates a file then again 
> it doesn't do nothing but shows the last file edited, whats the best way 
> to loop through files and display that file name in a Label's text 
> without skipping to the last one when the loop is finished?

Tkinter is event-driven, and you need to keep the event loop running to 
make sure that changes to the widgets makes it to the screen.

Usually, this is handled by the "mainloop" function, but if you're 
spending considerable time at the Python level, you need to call the 
"update" or "update_idletasks" methods from time to time to give Tkinter 
a chance to process incoming events.  In your case, you can simply call 
the method after you've modified the label:

     label.config(text="something")
     label.update()

Hope this helps!

</F>




More information about the Python-list mailing list