pack/sleep asynchronicity?

From: Harvey J. Stein <hjstein_at_math.huji.ac.il>
Date: Sat, 24 Dec 1994 21:32:52 +0200

john lewis writes:
> I would like to bring up some widgets, then wait for a bit
> (an external process to finish, but a sleep would be equivalent)
> before introducing some more into the same frame.
>
> In the example below, none of the packs come into effect until
> the end of the script, i.e. the sleep executes out of order.
> This is true even if stk is started with -sync.
>
> Any ideas?
>
> ----------------
>
> (frame '.main)
> (pack '.main :expand #t :fill "both")
>
> (label '.main.l :anchor "center" :text "xxx")
> (pack '.main.l :fill "both")
>
> (system "sleep 3") ;; want to sleep a bit before bringing up the button
>
> (button '.main.b :text "button" :command '(destroy "."))
> (pack '.main.b :fill "both")

I think your problem is that Tk never updates the screen until the
process is idle.

So, before doing the sleep 3, do an (update "idletasks"), for example.

Also, you might want to do (after 3000) instead of (system "sleep 3").

Good luck,

Dr. Harvey J. Stein
Berger Financial Research
hjstein_at_math.huji.ac.il
Received on Sat Dec 24 1994 - 20:34:29 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST