proc displayInfo {} {
.mv.c create text 10 10 -text "A Moving Story" -tags st
.mv.c create text 20 30 -text "by" -tags st
.mv.c create text 15 50 -text "Venkat V V S S Sastry" -tags st
bell
movie st 250
.mv.c.but configure -text Stop -command \
{global id
bell
after cancel $id
.mv.c.but configure -text {The End}
after 10000
.mv.c.but configure -text Quit -command {exit}
}
}
The first three lines of script in "displayInfo" create three separate text objects in the canvas at x,y locations given by (10,10), (20,30), and (15,50). All three strings are assigned a single tag name "st".
The command bell rings the display of the applications main window. You can give bell a -displayof option to specify the display of a particular window. Then "displayInfo" invokes the procedure "movie" with the tag name "st" and an interval (250 milliseconds in this case) as arguments. The label on the button changes to "Stop".
The buttons -command option is reconfigured to cancel the execution of the delayed command given by the identifier "id". If the user clicks on the button, the label changes again to "The End" to mark the end of the animation. After an elapse of 10 seconds the button displays "Quit" for the user to click on to exit the application.