[Tutor] cannot get a label message to display immediately

Alan Gauld alan.gauld at btinternet.com
Sat Aug 15 09:21:36 CEST 2015


On 15/08/15 06:44, Bill Allen wrote:

> In my case, as simple as this:
>
> def processing(*args):   #my initial button click calls this
>      info.set('PROCESSING, PLEASE WAIT...')   #the label message I was
>      root.after(1000, process_part)  #the long running data process

That works for getting the message printed but it still leaves
the problem that your UI locks up during the long process.
If its only for a couple of seconds it might be a mild hiccup
but if your processing took, say 5s or longer, the user is
likely to think the program is broken and may force kill
the window or process or take similarly drastic action.

That's why it's important to break the long process into
chunks and call after() from within it. (or run it in the
background) To do otherwise is to risk having your process
cut short in mid flow with the data potentially only
half processed - and you won't know which half!

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list