Version 0 of A little rain forecaster

Updated 2002-05-15 14:45:23

Richard Suchenwirth 2002-05-15 - The following code gets maps of predicted precipitation (for North Atlantic, Europe, and parts of adjacent continents) for the next 15 days, in 12 hour steps, from a German weather station via HTTP and displays them in a canvas.

 proc cycle listName {
    upvar 1 $listName list
    set res [lindex $list 0]
    set list [concat [lrange $list 1 end] [list $res]]
 }
 proc every {ms body} {eval $body; after $ms [info level 0]}

 package require http
 http::config -proxyhost proxy -proxyport 80

 set prefix http://129.13.102.67/pics/Rvtmrf
 set suffix 4.gif

 pack [canvas .c -width 800 -height 680] -expand 1 -fill both

 wm title . "Loading..."

 for {set i 12} {$i<=504} {incr i 12} {
    set gif [http::data [http::geturl $prefix$i$suffix]]
    if ![catch {lappend ims [image create photo im$i -data $gif]}] {
        .c create image 0 0 -anchor nw -image im$i -tag im$i
    }
 }
 wm title . "Film"

 bind . q exit
 bind . <Control-c> exit

 every 1000 {.c raise [lindex [cycle ::ims] 0];puts ims:$::ims}

Arts and crafts of Tcl-Tk programming