Posted to tcl by egavilan at Fri Apr 04 23:27:20 GMT 2008view raw

  1. This version copies the next index over the previous.
  2.  
  3. image source at http://www.eats-edu.com.ar/sva/modulo_1_archivos/4-Stroke-Engine.gif
  4.  
  5.  
  6. if {![file exists [set imgfile [lindex $argv 0]]]} {
  7. print "Uso: $argv0 filename.gif"
  8. exit
  9. }
  10.  
  11. proc animate {img nimg ms} {
  12. scan [$nimg cget -format] "GIF -index %d" index
  13.  
  14. puts $index
  15. incr index
  16. if [catch {
  17. $nimg configure -format "GIF -index $index"
  18. }] {
  19. $nimg configure -format "GIF -index 0"
  20. }
  21. $img copy $nimg
  22. after $ms [info level 0]
  23. }
  24.  
  25. set img [image create photo -file $imgfile -format "GIF -index 0"]
  26. set nimg [image create photo -file $imgfile -format "GIF -index 1"]
  27.  
  28. pack [label .l -image $img -padx 20 -pady 20 -bg white] -side left
  29.  
  30. after 2000 animate $img $nimg 20