summaryrefslogtreecommitdiffstats
path: root/library/demos/ttkprogress.tcl
blob: 06e6a21241b3b209fc7b1291456df9cc7257f4ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# ttkprogress.tcl --
#
# This demonstration script creates several progress bar widgets.
#
# RCS: @(#) $Id: ttkprogress.tcl,v 1.1 2007/10/22 14:21:16 dkf Exp $

if {![info exists widgetDemo]} {
    error "This script should be run from the \"widget\" demo."
}

package require Tk
package require Ttk

set w .ttkprogress
catch {destroy $w}
toplevel $w
wm title $w "Progress Bar Demonstration"
wm iconname $w "ttkprogress"
positionWindow $w

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."
grid $w.msg - -sticky ew

proc doBars {op args} {
    foreach w $args {
	$w $op
    }
}
ttk::progressbar $w.p1 -mode determinate
ttk::progressbar $w.p2 -mode indeterminate
ttk::button $w.start -text "Start Progress" -command [list \
	doBars start $w.p1 $w.p2]
ttk::button $w.stop -text "Stop Progress" -command [list \
	doBars stop $w.p1 $w.p2]

grid $w.p1 - -pady 5 -padx 10
grid $w.p2 - -pady 5 -padx 10
grid $w.start $w.stop -padx 10 -pady 5
grid configure $w.start -sticky e
grid configure $w.stop -sticky w

## See Code / Dismiss buttons
set btns [addSeeDismiss $w.buttons $w]
grid $btns - - -sticky ews
grid columnconfigure $w 2 -weight 1
grid rowconfigure $w $btns -weight 1