[Richard Suchenwirth] 2005-07-09 - There are several ways to catch the attention of a user to a window, e.g. an alert or dialog - flashing colors are sometimes used. One can also make a [toplevel] "jitter", i.e. move slightly to the left and bottom, and back again. One pixel is enough to catch attention, as windows usually (and thankfully!) stand still. I saw this effect in an ad on AOL's home page, and even though I'd hardly ever use it, in this Saturday breakfast fun project I wanted to code it - "because we can" :) Here it is, in bare-bones fashion. If you drag the window, it will snap back to its original position. ====== proc jitter {w {dt 200}} { if [winfo exists $w] { after $dt regexp {\+(\d+)\+(\d+)} [wm geometry $w] -> x y wm geometry $w +[expr $x+1]+[expr $x+1] update idletasks after $dt wm geometry $w +$x+$y after 1 [list jitter $w $dt] } } #-- Testing pack [label .l -text "Jitter test"] jitter . bind . {exec wish $argv0 &; exit} ====== [MG] July 9 2005 - Edited the ''after 1 ...'' line in the jitter proc, so that it also passes the time, $dt. Otherwise, using anything but the default only had an effect the first time, and was afterwards ignored. [LWS] - Oct 9 2005 - Parameterized - so you can stop the thing, too! ====== proc jitter {w {msdelay 100} {times 20} {dx 2} {dy 2}} { if { [winfo exists $w] } { #regexp {\+(\d+)\+(\d+)} [wm geometry $w] -> x y scan [wm geometry $w] "%*dx%*d+%d+%d" x y wm geometry $w +[expr {$x+$dx}]+[expr {$y+$dy}] update idletasks after $msdelay wm geometry $w +$x+$y if {$times} { after $msdelay [list jitter $w $msdelay [expr {$times - 1}] $dx $dy] } } } ====== [MG] Made some changes to speed it up a little: * Use [scan] instead of [regexp] to parse the results of ''wm geometry'' * Braced the [expr] calls - the last goes down from 7 ms to 0 ms, as reported by [time], just by being braced! * Braced the first [if], for the same reason [PT] Believe it or not, this is used in the MSN chat client. People can cause the other users window to shake to catch their attention. The above code might be handy in aMSN which is a Tcl implementation of MSN chat. <> Animation | Arts and crafts of Tcl-Tk programming