Welcome to Progress Bar’s documentation!¶
- Usage
- Examples
- Contributing
- Installation
- progressbar.shortcuts module
- progressbar.bar module
ProgressBarMixinBaseProgressBarMixinBase.term_widthProgressBarMixinBase.widgetsProgressBarMixinBase.max_errorProgressBarMixinBase.prefixProgressBarMixinBase.suffixProgressBarMixinBase.left_justifyProgressBarMixinBase.widget_kwargsProgressBarMixinBase.custom_lenProgressBarMixinBase.initial_start_timeProgressBarMixinBase.poll_intervalProgressBarMixinBase.min_poll_intervalProgressBarMixinBase.num_intervalsProgressBarMixinBase.next_updateProgressBarMixinBase.valueProgressBarMixinBase.previous_valueProgressBarMixinBase.min_valueProgressBarMixinBase.max_valueProgressBarMixinBase.end_timeProgressBarMixinBase.start_timeProgressBarMixinBase.seconds_elapsedProgressBarMixinBase.extraProgressBarMixinBase.get_last_update_time()ProgressBarMixinBase.set_last_update_time()ProgressBarMixinBase.last_update_timeProgressBarMixinBase.start()ProgressBarMixinBase.update()ProgressBarMixinBase.finish()ProgressBarMixinBase.data()ProgressBarMixinBase.started()ProgressBarMixinBase.finished()
ProgressBarBaseDefaultFdMixinResizableMixinStdRedirectMixinProgressBarDataTransferBarNullBar
- progressbar.base module
- progressbar.utils module
AttributeDictStreamWrapperStreamWrapper.capturingStreamWrapper.excepthook()StreamWrapper.flush()StreamWrapper.listenersStreamWrapper.logging_handlersStreamWrapper.needs_clear()StreamWrapper.original_excepthookStreamWrapper.start_capturing()StreamWrapper.stderrStreamWrapper.stdoutStreamWrapper.stop_capturing()StreamWrapper.unwrap()StreamWrapper.unwrap_excepthook()StreamWrapper.unwrap_logging()StreamWrapper.unwrap_stderr()StreamWrapper.unwrap_stdout()StreamWrapper.update_capturing()StreamWrapper.wrap()StreamWrapper.wrap_excepthook()StreamWrapper.wrap_logging()StreamWrapper.wrap_stderr()StreamWrapper.wrap_stdout()StreamWrapper.wrapped_excepthookStreamWrapper.wrapped_loggingStreamWrapper.wrapped_stderrStreamWrapper.wrapped_stdout
WrappingIOWrappingIO.bufferWrappingIO.capturingWrappingIO.close()WrappingIO.fileno()WrappingIO.flush()WrappingIO.flush_target()WrappingIO.isatty()WrappingIO.listenersWrappingIO.needs_clearWrappingIO.read()WrappingIO.readable()WrappingIO.readline()WrappingIO.readlines()WrappingIO.seek()WrappingIO.seekable()WrappingIO.targetWrappingIO.tell()WrappingIO.truncate()WrappingIO.writable()WrappingIO.write()WrappingIO.writelines()
deltas_to_seconds()len_color()no_color()
- progressbar.widgets module
AbsoluteETAAdaptiveETAAdaptiveTransferSpeedAnimatedMarkerAutoWidthWidgetBaseBarBouncingBarColoredMixinCounterCurrentTimeDataSizeDynamicMessageETAFileTransferSpeedFormatCustomTextFormatLabelFormatLabelBarFormatWidgetMixinGranularBarGranularMarkersJobStatusBarMultiProgressBarMultiRangeBarPercentagePercentageLabelBarPostfixReverseBarRotatingMarkerSamplesMixinSimpleProgressSmoothingETATFixedColorsTGradientColorsTimeSensitiveWidgetBaseTimerUnitProgressVariableVariableMixinWidgetBaseWidthWidgetMixincreate_marker()create_wrapper()format_unit_value()string_or_lambda()wrapper()
- History
progressbar2¶
A mature, typed terminal progress bar library for Python scripts that need custom widgets, clean output around prints and logs, multiple concurrent bars, unknown-length progress, and pipe-friendly CLI usage.
Install¶
pip install progressbar2
Quick start¶
import time
import progressbar
for item in progressbar.progressbar(range(100), desc='Loading'):
time.sleep(0.02)
Progress with clean logs¶
import sys
import time
import progressbar
with progressbar.ProgressBar(
total=24,
desc='Build',
fd=sys.stdout,
redirect_stdout=True,
line_breaks=False,
is_terminal=True,
enable_colors=True,
term_width=112,
) as bar:
for step in range(24):
if step in {8, 16}:
print(f'log: completed step {step}')
bar.update(step + 1, force=True)
time.sleep(0.005)
Multiple bars¶
import io
import re
import progressbar
fd = io.StringIO()
multibar = progressbar.MultiBar(
fd=fd,
total=24,
enable_colors=True,
initial_format=None,
finished_format=None,
remove_finished=None,
sort_reverse=False,
term_width=112,
)
build = multibar['build']
test = multibar['test']
terminal_control_re = re.compile(r'\x1b\[[0-9;]*[A-Za-ln-z]')
def emit_frame():
output = terminal_control_re.sub('', fd.getvalue())
for line in output.split('\r'):
line = line.strip()
if line:
print(line)
print('\f', end='')
fd.seek(0)
fd.truncate(0)
multibar.render(force=True, flush=True)
emit_frame()
for step in range(24):
build.update(step + 1, force=True)
test_value = min(24, max(0, round((step - 3) * 1.2)))
test.update(test_value, force=True)
multibar.render(force=True, flush=True)
emit_frame()
Unknown length and animated bars¶
import sys
import progressbar
with progressbar.ProgressBar(
max_value=progressbar.UnknownLength,
fd=sys.stdout,
line_breaks=False,
is_terminal=True,
enable_colors=True,
term_width=112,
) as bar:
for value in range(0, 120, 10):
bar.update(value, force=True)
CLI usage¶
progressbar --progress --timer --eta --rate --bytes input.bin -o output.bin
Feature highlights¶
Works as an iterable wrapper or a manually updated progress bar.
Supports custom widgets, colors, granular bars, animated markers, and labels.
Handles unknown-length iterators.
Supports multiple concurrent progress bars with
MultiBar.Redirects stdout/stderr so regular output does not corrupt the active bar.
Includes a pipe-friendly
progressbarcommand.Ships typed package metadata.
Known terminal caveats¶
JetBrains IDEs need “Enable terminal in output console” for advanced terminal behavior such as
MultiBar.IDLE does not support terminal progress bars.
Jupyter buffers stdout; call
sys.stdout.flush()when output appears late.
Project history¶
progressbar2 is based on the old Python progressbar package that was published on the now defunct Google Code. Since that project was completely abandoned by its developer and the developer did not respond to email, I decided to fork the package.
This package is still backwards compatible with the original progressbar package so you can safely use it as a drop-in replacement for existing projects.
Links¶
Documentation: https://progressbar-2.readthedocs.org/en/latest/
Bug reports: https://github.com/WoLpH/python-progressbar/issues
Package homepage: https://pypi.python.org/pypi/progressbar2