* snosniv <
[email protected]>
| proc togglePwr {} {
| global POWsel f9
| if {$POWsel == 1} {
| # Power label
| $f9.lb00 configure -text "Watts" -bg lightblue1 -fg $Watt_Col
| after 500 $f9.lb00 configure -bg grey
| after 500 $f9.lb00 configure -bg lightblue1
| } else {
| $f9.lb00 configure -text "FTP" -bg green-fg $FTP_Col
| after 500 $f9.lb00 configure -bg grey
| after 500 $f9.lb00 configure -bg green
| }
| }
| So, ignoring the 'after' commands, the label changes text & colour just fine, | but I'd like to flash the background just a few times somehow?
| The added after is not doing anything I can see.
It *is* doing something, but since you set up *two* after commands for
the same interval, they run immediately after each other, the second
undoing the effect of the first.
Either use
after 500 [list $f9.lb00 configure -bg grey]
after 1000 [list $f9.lb00 configure -bg lightblue1]
(note: different intervals) or set up a proc which gets a count as
argument, decrs the count and calls itself via [after] while the
count is > 0
proc do_n_times {n interval} {
# do something
puts "do_n_times $n $interval [clock milliseconds]"
incr n -1
if {$n > 0} {
after $interval [list do_n_times $n $interval]
}
}
do_n_times 5 500
=>
do_n_times 5 500 1678979708511
do_n_times 4 500 1678979709011
do_n_times 3 500 1678979709511
do_n_times 2 500 1678979710011
do_n_times 1 500 1678979710512
You may want to add arguments for the widgets to change etc.
HTH
R'
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)