[Tutor] Simple Tkinter question (fwd)
alan.gauld at freenet.co.uk
Fri Oct 7 10:31:39 CEST 2005
>> The problem is that the GUI needs control back to be able to update the
>> GUI display.
> Thanks, but what I don't understand is:
> Why doesn't the call tv.set("string") update what's on the screen.
> Tkinter has control at that point, and there's no reason to delay updating
> the screen,
> is there?
The way most GUIs work is that the display is held in a buffer in memory.
The buffer gets updated by commands then between events the GUI reftreshes
the display. In most cases this results in smoother operation with less
on the screen. Unfortunately when a method wants to do lots of updates to
the same field the intermediate values are lost so you need some way of
allowing the refresh to take place.
> I have a bunch of lines selected on the screen. I'm using Pmw. This
> tuple has a number of items I need to play. While the sound is playing, I
> to display the name of the sound on the GUI. (The playing is done by a
> that writes to the serial port - that is, I call a function with the
> filename of
> the sound, and it plays it).
The best approach to anything in GUI programming(and in real-time work
of any sort!) is to propcess things one at a time, avoiding loops of any
When you have multiple items to process create an event for each
subsequent action and allow the event loop to act as your loop.
Thats what the after() function does (Thanks Danny I hadn't seen that one!).
Author of the learn to program web tutor
More information about the Tutor