Next / Previous / Contents

39. ttk.Progressbar

The purpose of this widget is to reassure the user that something is happening. It can operate in one of two modes:

  • In determinate mode, the widget shows an indicator that moves from beginning to end under program control.

  • In indeterminate mode, the widget is animated so the user will believe that something is in progress. In this mode, the indicator bounces back and forth between the ends of the widget.

In either mode, the current position of the indicator has a numeric value. You can specify a maximum value, and you can set the indicator value directly. You may also specify that the indicator value moves a given amount every time a given time interval passes.

To create a new ttk.Progressbar widget as the child of a given parent widget:

    w = ttk.Progressbar(parent, option=value, ...)

The options for this constructor are given in Table 54, “ttk.Progressbar options”.

Table 54. ttk.Progressbar options

class_ The widget class name. This may be specified when the widget is created, but cannot be changed later. For an explanation of widget classes, see Section 27, “Standardizing appearance”.
cursor The cursor that will appear when the mouse is over the checkbutton; see Section 5.8, “Cursors”.
length The size of the widget along its long axis as a dimension.
maximum The maximum value of the indicator; default is 100.
mode

If your program cannot accurately depict the relative progress that this widget is supposed to display, use mode='indeterminate'. In this mode, a rectangle bounces back and forth between the ends of the widget once you use the .start() method.

If your program has some measure of relative progress, use mode='determinate'. In this mode, your program can move the indicator to a specified position along the widget's track.

orient This options specifies the orientation: use orient=tk.HORIZONTAL or orient=tk.VERTICAL.
style The style to be used in rendering this widget; see Section 49, “Using and customizing ttk styles”.
takefocus By default, a ttk.Progressbar will not be included in focus traversal; see Section 53, “Focus: routing keyboard input”. To add the widget to focus traversal, use takefocus=True.
variable Use this option to link a control variable to the widget so that you can get or set the current value of the indicator.

Methods on a ttk.Progressbar include those described in Section 46, “Methods common to all ttk widgets” plus:

.start([interval])

Start moving the indicator every interval milliseconds; the default is 50ms. Each time, the indicator is moved as if you called the .step() method.

.step([delta])

This method increases the indicator value by delta; the default increment is 1.0. In determinate mode, the indicator will never exceed the value of the maximum option. In indeterminate mode, the indicator will reverse direction and count down once it reaches the maximum value.

.stop()

This method stops the automatic progress that was started by calling the .start() method.