progress.tcl (1089B)
1 # 2 # Ttk widget set: progress bar utilities. 3 # 4 5 namespace eval ttk::progressbar { 6 variable Timers ;# Map: widget name -> after ID 7 } 8 9 # Autoincrement -- 10 # Periodic callback procedure for autoincrement mode 11 # 12 proc ttk::progressbar::Autoincrement {pb steptime stepsize} { 13 variable Timers 14 15 if {![winfo exists $pb]} { 16 # widget has been destroyed -- cancel timer 17 unset -nocomplain Timers($pb) 18 return 19 } 20 21 set Timers($pb) [after $steptime \ 22 [list ttk::progressbar::Autoincrement $pb $steptime $stepsize] ] 23 24 $pb step $stepsize 25 } 26 27 # ttk::progressbar::start -- 28 # Start autoincrement mode. Invoked by [$pb start] widget code. 29 # 30 proc ttk::progressbar::start {pb {steptime 50} {stepsize 1}} { 31 variable Timers 32 if {![info exists Timers($pb)]} { 33 Autoincrement $pb $steptime $stepsize 34 } 35 } 36 37 # ttk::progressbar::stop -- 38 # Cancel autoincrement mode. Invoked by [$pb stop] widget code. 39 # 40 proc ttk::progressbar::stop {pb} { 41 variable Timers 42 if {[info exists Timers($pb)]} { 43 after cancel $Timers($pb) 44 unset Timers($pb) 45 } 46 $pb configure -value 0 47 } 48 49