Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem inserting pause between text messages

Status
Not open for further replies.

rubberscissors

Technical User
Oct 11, 2001
21
US
I've got a text widget that I've associated with a variable (x), and I'm trying to cause text messages to appear in the widget, with a pause in between each message. I tried the following:

$x insert end "Message 1\n"
after 300
$x insert end "Message 2\n"
after 300
$x insert end "Message 3\n"

When it's called, however, what it seems to do is wait right off the bat without printing the first message, then, when it's finished waiting it just prints all three messages. Does anyone know what I'm doing wrong? I'm using Tcl/Tk 8.3
 
I obtained what you want with:
Code:
  pack [text .t]
  .t insert end "Message 1\n"
  update
  after 3000
  .t insert end "Message 2\n"
  update
  after 3000 
  .t insert end "Message 3\n"
I changed the 300 ms to 3000 (3 s).
The two added 'update' ask Tk to display all changes immediatly.
I suppose that 'after 3000' does not call the event loop.

Good luck

ulis
 
That's right, ulis. When you give the after command only the number of milliseconds to sleep, it enters a "blocking" wait. It doesn't enter the event loop, and so it doesn't process outstanding events or refresh the screen during the time it's asleep.

By explicitly calling the update command before executing the after, you tell Tcl to process any pending events and refresh the screen before sleeping. - Ken Jones, President, ken@avia-training.com
Avia Training and Consulting, 866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top