1Tk::ProgressBar(3) perl/Tk Documentation Tk::ProgressBar(3)
2
3
4
6 Tk::ProgressBar - A graphical progress bar
7
9 use Tk::ProgressBar;
10
11 $progress = $parent->ProgressBar(
12 -width => 20,
13 -length => 200,
14 -anchor => 's',
15 -from => 0,
16 -to => 100,
17 -blocks => 10,
18 -colors => [0, 'green', 50, 'yellow' , 80, 'red'],
19 -variable => \$percent_done
20 );
21
22 $progress->value($position);
23
25 Tk::ProgressBar provides a widget which will show a graphical
26 representation of a value, given maximum and minimum reference values.
27
29 The following standard widget options are supported:
30
31 -borderwidth
32 -highlightthickness
33 Defaults to 0.
34
35 -padx
36 Defaults to 0.
37
38 -pady
39 Defaults to 0.
40
41 -relief
42 Defaults to "sunken"
43
44 -troughcolor
45 The color to be used for the background (trough) of the progress
46 bar. Default is to use grey55.
47
49 -anchor
50 This can be used to position the start point of the bar. Default is
51 'w' (horizontal bar starting from the left). A vertical bar can be
52 configured by using either 's' or 'n'.
53
54 -blocks
55 This controls the number of blocks to be used to construct the
56 progress bar. The default is to break the bar into 10 blocks.
57
58 -colors
59 Controls the colors to be used for different positions of the
60 progress bar. The colors should be supplied as a reference to an
61 array containing pairs of positions and colors.
62
63 -colors => [ 0, 'green', 50, 'red' ]
64
65 means that for the range 0 to 50 the progress bar should be green
66 and for higher values it should be red.
67
68 -from
69 This sets the lower limit of the progress bar. If the bar is set
70 to a value below the lower limt no bar will be displayed. Defaults
71 to 0. See the "-to" description for more information.
72
73 -gap
74 This is the spacing (in pixels) between each block. Defaults to 1.
75 Use 0 to get a continuous bar.
76
77 -length
78 Specifies the desired long dimension of the ProgressBar in screen
79 units (i.e. any of the forms acceptable to Tk_GetPixels). For
80 vertical ProgressBars this is the ProgressBars height; for
81 horizontal scales it is the ProgressBars width. The default length
82 is calculated from the values of "-padx", "-borderwidth",
83 "-highlightthickness" and the difference between "-from" and "-to".
84
85 -resolution
86 A real value specifying the resolution for the scale. If this value
87 is greater than zero then the scale's value will always be rounded
88 to an even multiple of this value, as will tick marks and the
89 endpoints of the scale. If the value is less than zero then no
90 rounding occurs. Defaults to 1 (i.e., the value will be integral).
91
92 -to This sets the upper limit of the progress bar. If a value is
93 specified (for example, using the "value" method) that lies above
94 this value the full progress bar will be displayed. Defaults to
95 100.
96
97 -variable
98 Specifies the reference to a scalar variable to link to the
99 ProgressBar. Whenever the value of the variable changes, the
100 ProgressBar will update to reflect this value. (See also the value
101 method below.)
102
103 -value
104 This can be used to set the current position of the progress bar
105 when used in conjunction with the standard "configure". It is
106 usually recommended to use the value method instead.
107
108 -width
109 Specifies the desired narrow dimension of the ProgressBar in screen
110 units (i.e. any of the forms acceptable to Tk_GetPixels). For
111 vertical ProgressBars this is the ProgressBars width; for
112 horizontal bars this is the ProgressBars height. The default width
113 is derived from the values of "-borderwidth" and "-pady" and
114 "-highlightthickness".
115
117 $ProgressBar->value(?value?)
118 If value is omitted, returns the current value of the ProgressBar.
119 If value is given, the value of the ProgressBar is set. If $value
120 is given but undefined the value of the option -from is used.
121
123 Graham Barr <gbarr@pobox.com>
124
126 Copyright (c) 1997-1998 Graham Barr. All rights reserved. This program
127 is free software; you can redistribute it and/or modify it under the
128 same terms as Perl itself.
129
130
131
132Tk804.034 2020-01-30 Tk::ProgressBar(3)