[Tutor] cannot get a label message to display immediately

Laura Creighton lac at openend.se
Fri Aug 14 19:19:42 CEST 2015


In a message of Fri, 14 Aug 2015 11:32:59 -0500, Bill Allen writes:
>I am working in Tkinter.   The scenario is that I click a button that
>starts a function running.   No problem there.   However, the function may
>take some time to run and I do not want the user to be worried.   I am
>wanting to immediately set a label when the function starts to say "Please
>Wait".  However, the label does not show up until the function completes.
>How do I get both actions to happen essentially at the same time, the
>writing of the label and the execution of the function?  I have no code to
>show on this one because I am lost in the weeds, not sure of the general
>way to go on this.
>
>
>Thanks,
>--Bill Allen

Have you ever used threads before?

The standard way to handle this problem is to run your gui in one thread
(the main thread) and then spawn a separate thread to handle any real
work that needs doing.

http://code.activestate.com/recipes/82965-threads-tkinter-and-asynchronous-io/

is one way to handle it, but if you've never used threads before, I
suspect it will be hard to understand.  I'm going to be busy for
several hours -- maybe somebody else here can explain.

Laura



More information about the Tutor mailing list