TProgressbar

A themed progress bar. Use it two ways:

TProgressbar is themed-only (it has no classic equivalent).

Determinate example

Drive value yourself as the work proceeds. (setTimeout / clearTimeout come from the built-in os module, imported below.)

import * as os from 'os';

const bar = app.TProgressbar({ maximum: 100, length: 240 });
bar.pack.configure({ fill: 'x', padx: 16, pady: 16 });

let done = 0;
const tick = () => {
  bar.value = done; // 0 … 100
  if (done < 100) {
    done += 10;
    os.setTimeout(tick, 200);
  }
};
tick();

Indeterminate example

const bar = app.TProgressbar({ mode: 'indeterminate', length: 240 });
bar.pack.configure({ fill: 'x', padx: 16, pady: 16 });

__native_tcl(bar._id, 'start', 12); // animate; arg is the step interval (ms)
// … later, when the work finishes:
// __native_tcl(bar._id, 'stop');

Options

Option Type Description
mode string 'determinate' (default) or 'indeterminate'.
value number Current amount, 0maximum (determinate). Also a readable/writable property.
maximum number The value that means "full" (default 100).
orient string 'horizontal' (default) or 'vertical' (creation-time only).
length number Length of the long axis, in pixels.
variable a *Var Bind value to a variable.
style string A ttk style name — themes provide striped / coloured variants.

Methods

value is a property (bar.value = 40). The animation commands are reached through the __native_tcl escape hatch:

Call Description
__native_tcl(bar._id, 'start', interval?) Start the indeterminate animation (interval ms between steps).
__native_tcl(bar._id, 'step', amount?) Advance value by amount (default 1).
__native_tcl(bar._id, 'stop') Stop the animation.

Plus the inherited widget methods — see Widget basics.

See also