progress.tcl 1.1 KB

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