[Tutor] cannot get a label message to display immediately
wallenpb at gmail.com
Sat Aug 15 07:44:58 CEST 2015
On Fri, Aug 14, 2015 at 3:06 PM, Alan Gauld <alan.gauld at btinternet.com>
> That's the problem right there. You should never kick of an event handler
> that takes a long time to run. Either:
> 1) Kick of a separate thread to do the back end processing
> 2) break the function into short chunks and use a timer
> (after() in Tkinter) to repeatedly fire the function
> (this is the traditional GUI approach)
> 3) In Python 3.4 use asyncore to create an asynchronous event
> loop and feed the functions into that.
> def long_handler()
> update_status() # change the GUI
> getItem(data) # fetch one item from data
> processItem(item) # process one item,
> if data: # is there any more?
> after(20, long_handler) # then go again after 20ms
> Follow my photo-blog on Flickr at:
> Alan and everyone that responded,
Excellent information! It was the concepts that I was falling short on an
this helped me a great deal. In my particular situation, I found using the
after() method indeed worked just fine and was quite simple to implement.
In my case, as simple as this:
def processing(*args): #my initial button click calls this
''' display messages in the information message_frame while the data
is processed '''
info.set('PROCESSING, PLEASE WAIT...') #the label message I was
wanting to get out there to the user
root.after(1000, process_part) #the long running data process
More information about the Tutor