[Tkinter-discuss] update of elements in GUI

Cameron Laird Cameron at phaseit.net
Tue Aug 17 16:25:05 CEST 2010


On Wed, Aug 18, 2010 at 12:50:38AM +1200, Alex Ter-Sarkissov wrote:
			.
			.
			.
> I have some elements on the screen (Labels, most importantly) which content
> has to be updated every iteration of the algorithm run, e.g. "Iteration ="
> [i] for i in range(n). I've tried using mainframe.update_idletasks()
> and Label(mainframe.update_ideltasks(),textvariable=var).grid(column=1,row=1),
> but without success so far. In MATLAB this command is drawnow.
			.
			.
			.
I believe I understand your description.

For a "quick fix", I recommend you experiment with update() (as 
opposed to update_idletasks()) applied to mainframe.

For better long-term maintainability, though, you almost 
certainly should "return to the event loop" on each iteration
of your run (there are also multi-threading approaches, but 
they're somewhat trickier to code correctly).

You might find <URL: http://wiki.tcl.tk/1255 >, <URL: 
http://wiki.tcl.tk/1526 >, and <URL:
http://osdir.com/ml/python.tkinter/2008-05/msg00014.html > of
interest.  


More information about the Tkinter-discuss mailing list