Posted to tcl by jdc at Wed Aug 08 06:32:00 GMT 2012view pretty
package require Tk
proc timer {widget seconds} {
toplevel $widget
ttk::progressbar $widget.pb1 -orient horizontal -mode determinate -maximum $seconds
grid $widget.pb1
update idletasks
# Do some real work here for $seconds seconds
for {set i 0} {$i < $seconds} {incr i} {
after 1000 ;# Just waiting in this example, might as well do something useful here
$widget.pb1 step ;# After some part of the work, advance the progressbar
update idletasks;# Needed to update the progressbar
}
# Done, clean up the dialog and progressbar
destroy $widget
}
pack [button .b1 -text "Upgrade" -command { timer .new 10 }]