#! /bin/local/wish
set currenttime 0
set cooktime 0

frame .entryframe
label .timedisplay  -relief sunken  -width 7  -text 0
button .entryframe.frozen -text "Frozen Veg" -command {setTimer 40}
button .entryframe.beverage -text "beverages" -command {setTimer 20}
button .entryframe.potato -text "Bake Potato" -command {setTimer 25}
button .entryframe.30sec -text "Quick 30sec" -command  {setTimer 30}
button .cook -text Cook -command  startCook
button .clear -text Clear -command  ClearTime

pack .entryframe -side right
pack .timedisplay -side top
pack .entryframe.frozen -side top
pack .entryframe.beverage -side bottom
pack .entryframe.potato -side top
pack .entryframe.30sec -side bottom
pack .cook -side bottom
pack .clear -side bottom



proc startCook { } {
global cooktime

set i $cooktime
	while {$i >0 && $cooktime >0 }  {
	after 500
	set i [expr $i - 1]
	.timedisplay config -text $i
	update
	}
	.timedisplay config -text 0
	update
	set cooktime 0
}

proc setTimer { t } {
global cooktime
set cooktime $t
.timedisplay config -text $t
update
}

proc ClearTime {} {
global cooktime
set cooktime 0
update
}

