ttkprogress.tcl 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # ttkprogress.tcl --
  2. #
  3. # This demonstration script creates several progress bar widgets.
  4. if {![info exists widgetDemo]} {
  5. error "This script should be run from the \"widget\" demo."
  6. }
  7. package require Tk
  8. set w .ttkprogress
  9. catch {destroy $w}
  10. toplevel $w
  11. wm title $w "Progress Bar Demonstration"
  12. wm iconname $w "ttkprogress"
  13. positionWindow $w
  14. ttk::label $w.msg -font $font -wraplength 4i -justify left -text "Below are two progress bars. The top one is a \u201Cdeterminate\u201D progress bar, which is used for showing how far through a defined task the program has got. The bottom one is an \u201Cindeterminate\u201D progress bar, which is used to show that the program is busy but does not know how long for. Both are run here in self-animated mode, which can be turned on and off using the buttons underneath."
  15. pack $w.msg -side top -fill x
  16. ## See Code / Dismiss buttons
  17. set btns [addSeeDismiss $w.buttons $w]
  18. pack $btns -side bottom -fill x
  19. ttk::frame $w.f
  20. pack $w.f -fill both -expand 1
  21. set w $w.f
  22. proc doBars {op args} {
  23. foreach w $args {
  24. $w $op
  25. }
  26. }
  27. ttk::progressbar $w.p1 -mode determinate
  28. ttk::progressbar $w.p2 -mode indeterminate
  29. ttk::button $w.start -text "Start Progress" -command [list \
  30. doBars start $w.p1 $w.p2]
  31. ttk::button $w.stop -text "Stop Progress" -command [list \
  32. doBars stop $w.p1 $w.p2]
  33. grid $w.p1 - -pady 5 -padx 10
  34. grid $w.p2 - -pady 5 -padx 10
  35. grid $w.start $w.stop -padx 10 -pady 5
  36. grid configure $w.start -sticky e
  37. grid configure $w.stop -sticky w
  38. grid columnconfigure $w all -weight 1