ttk::progressbar
Guide: Themed widgets (ttk)
Makes a themed progress bar: a bar that shows how much of a task is done, or that a task runs.
ttk::progressbar PATHNAME ?OPTION VALUE ...?
Description
Makes a themed progress bar with the name PATHNAME and the options of the call, and makes the command PATHNAME for the widget commands below. The bar has a track and a bar inside it.
In the mode determinate, the bar fills the fraction -value / -maximum of the track, and a change of the value eases from the shown length. In the mode indeterminate, a short bar moves along the track to show that a task runs. start moves the bar with a timer, and stop ends the timer.
The parent of PATHNAME must exist, and PATHNAME must not. The class of the progress bar is TProgressbar, the name of its style.
Widget commands
| Command | Description |
|---|---|
ttk::progressbar step | Adds an amount to the value. |
ttk::progressbar start | Starts a timer that calls step at each interval. |
ttk::progressbar stop | Stops the timer of start. |
ttk::progressbar state | Gives the state flags of the widget, or turns flags on and off. |
ttk::progressbar instate | Tests the state flags of the widget, and runs a script when they match. |
ttk::progressbar identify | Gives the name of the element of the widget at a point. |
ttk::progressbar cget | Gives the value of an option of the widget. |
ttk::progressbar configure | Gives or sets the options of the widget. |
Options
| Option | Type | Default | Database name | Description |
|---|---|---|---|---|
-class | class name | empty | The class of the widget for the option database and for the bindings, set only at creation. | |
-cursor | cursor name | empty | cursor | The shape of the pointer over the widget. |
-length | screen distance | 100 | length | The length of the track. |
-maximum | double | 100 | maximum | The value of a full bar. |
-mode | mode | determinate | mode | Whether the bar shows an amount of work or only that a task runs. |
-orient | orientation | horizontal | orient | The direction of the widget: horizontal or vertical. |
-phase | integer | 0 | phase | A counter for the animation of a theme. |
-style | style name | empty | style | The style of the widget, such as TProgressbar or a style of the script such as Accent.TProgressbar. |
-takefocus | boolean, empty, or script | empty | takeFocus | Whether the Tab key can move the focus to the widget. |
-value | double | 0.0 | value | The current value of the bar. |
-variable | variable name | empty | variable | A global variable linked to the value of the bar. |
-class CLASS
The class of the widget for the option database and for the bindings, set only at creation.
The class name replaces the class of the style, such as TProgressbar, in winfo class and in the bind tags of the widget. Give it in the call that makes the widget. A later configure of the option gives an error.
% ttk::progressbar .tpbcl -class Fancy
> winfo class .tpbcl
Fancy
% ttk::progressbar .tpbcl3
> winfo class .tpbcl3
TProgressbar% ttk::progressbar .tpbcl2
> .tpbcl2 configure -class Other
attempt to change read-only option
-errorcode NONE-cursor CURSOR
The shape of the pointer over the widget.
Each value side by side: the contact sheet of the cursors
A cursor name of Tk, such as hand2 or xterm. An empty value uses the cursor of the parent.
% ttk::progressbar .tpbcu -cursor hand2
> .tpbcu cget -cursor
hand2ztk stores each value of the option with no check.
-length DISTANCE
The length of the track.
The width of a horizontal bar, or the height of a vertical bar. A geometry manager can stretch the bar to another length.

-length 60
-length 100
-length 200-value 40.% ttk::progressbar .tpble -length 200
> winfo reqwidth .tpble
200% ttk::progressbar .tpble2 -length x
bad screen distance "x"
-errorcode TK VALUE PIXELS-maximum NUMBER
The value of a full bar.
The bar fills the fraction -value / -maximum of the track. A step past the maximum goes on from 0.

-maximum 100
-maximum 50-value 40.% ttk::progressbar .tpbma -maximum 10
> .tpbma step 25
> .tpbma cget -value
5.0% ttk::progressbar .tpbma2 -maximum x
expected floating-point number but got "x"
-errorcode TCL VALUE NUMBER-mode MODE
Whether the bar shows an amount of work or only that a task runs.
The mode sets how the bar draws the value.
| Value | Description |
|---|---|
determinate | The bar fills the fraction -value / -maximum of the track. |
indeterminate | A short bar moves back and forth along the track, and -value sets its place. |

-mode determinate
-mode indeterminate-value 40.% ttk::progressbar .tpbmo -mode indeterminate
> .tpbmo cget -mode
indeterminate% ttk::progressbar .tpbmo2 -mode bogus
bad mode "bogus": must be determinate or indeterminate
-errorcode TCL LOOKUP INDEX mode bogus-orient ORIENT
The direction of the widget: horizontal or vertical.
A horizontal widget runs from left to right, and a vertical widget from top to bottom.
Values: horizontal, vertical.

-orient horizontal
-orient vertical-value 40.% ttk::progressbar .tpbor -orient vertical
> expr {[winfo reqheight .tpbor] > [winfo reqwidth .tpbor]}
1% ttk::progressbar .tpbor2 -orient diagonal
bad orient "diagonal": must be horizontal or vertical
-errorcode TCL LOOKUP INDEX orient diagonal-phase INTEGER
A counter for the animation of a theme.
Tk keeps the option for a theme that animates the bar. ztk stores the value, and step does not change it.
% ttk::progressbar .tpbph
> .tpbph step
> .tpbph cget -phase
0% ttk::progressbar .tpbph2 -phase x
expected integer but got "x"
-errorcode TCL VALUE NUMBER-style STYLE
The style of the widget, such as TProgressbar or a style of the script such as Accent.TProgressbar.
An empty value uses the style TProgressbar. A style name of the script ends with the name of the base style, such as Accent.TProgressbar, and ttk::style configure and ttk::style map give it its options. A style with no settings looks like its base style.
% ttk::style configure Accent.TProgressbar -foreground white
> ttk::progressbar .tpbsy -style Accent.TProgressbar
> .tpbsy cget -style
Accent.TProgressbarztk stores each value of the option with no check, as Tk 8.6.16 does at creation.
-takefocus VALUE
Whether the Tab key can move the focus to the widget.
1 puts the widget in the order of the Tab key, and 0 leaves it out. The default empty value uses the default rule of Tk, and this widget is not in the order of the Tab key with it. A script runs with the path of the widget appended, and its result is the answer.
% ttk::progressbar .tpbtf -takefocus 1
> .tpbtf cget -takefocus
1ztk stores each value of the option with no check.
-value NUMBER
The current value of the bar.
In the mode determinate, the value sets the length of the bar. A value above -maximum draws a full bar and stays as it is.

-value 0
-value 40
-value 100% ttk::progressbar .tpbva -value 150
> .tpbva cget -value
150% ttk::progressbar .tpbva2 -value x
expected floating-point number but got "x"
-errorcode TCL VALUE NUMBER-variable VAR
A global variable linked to the value of the bar.
A change of the variable sets -value, and step sets the variable. The bar does not create the variable.
% ttk::progressbar .tpbvr -variable tpbvr
> set tpbvr 30
> .tpbvr step 5
> set tpbvr
35.0Each name is a valid variable name.
Returns
PATHNAME.
Examples
% ttk::progressbar .load -maximum 10
> .load step 4
> .load cget -value
4.0
% winfo class [ttk::progressbar .busy -mode indeterminate]
TProgressbar
Errors
% ttk::progressbar .x -mode spin
bad mode "spin": must be determinate or indeterminate
-errorcode TCL LOOKUP INDEX mode spin
% ttk::progressbar .twice
> ttk::progressbar .twice
window name "twice" already exists in parent
-errorcode TK VALUE WINDOW EXISTS
# The parent .no does not exist.
% ttk::progressbar .no.p
bad window path name ".no"
-errorcode TK LOOKUP WINDOW .no
% ttk::progressbar
wrong # args: should be "ttk::progressbar pathName ?-option value ...?"
-errorcode TCL WRONGARGS
Differences from Tcl
-cursoraccepts each value with no check. Tk 8.6.16 gives an error for a cursor name that does not exist.- The errors of
state,instate,identify, and of an unknown widget command have the error codeNONE. Tk 8.6.16 gives a code such asTTK VALUE STATEorTCL LOOKUP INDEX. The error of-underlinehas the codeTCL VALUE NUMBER, where Tk 8.6.16 givesTCL VALUE INTEGER. - The states
activeandhoverare one flag, sostate activeturns on both. - The errors of
stepandstarthave the error codeNONE, and the error of a wrong count of arguments ofstepnames the argument?amount?. Tk 8.6.16 givesTCL WRONGARGSorTCL VALUE NUMBER, and names the argument?stepAmount?. The error of-phasehas the codeTCL VALUE NUMBER, where Tk 8.6.16 givesTCL VALUE INTEGER. stopkeeps the value. Tk 8.6.16 sets the value to 0.- A vertical bar asks for 8 pixels more than
-length. Tk 8.6.16 asks for-length.
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztk 1.0.0-beta.1