Skip to content

Repository files navigation

Easy progress reporting for Python

pypi

Demo

Bars

There are 6 progress bars to choose from:

  • Bar
  • ChargingBar
  • FillingSquaresBar
  • FillingCirclesBar
  • IncrementalBar
  • ShadyBar

To use them, just call next to advance and finish to finish:

fromprogress.barimportBarbar=Bar('Processing', max=20)
foriinrange(20):
# Do some workbar.next()
bar.finish()

The result will be a bar like the following:

Processing |############# | 42/100

To simplify the common case where the work is done in an iterator, you can use the iter method:

foriinBar('Processing').iter(it):
# Do some work

Progress bars are very customizable, you can change their width, their fill character, their suffix and more:

bar=Bar('Loading', fill='@', suffix='%(percent)d%%')

This will produce a bar like the following:

Loading |@@@@@@@@@@@@@ | 42%

You can use a number of template arguments in message and suffix:

NameValue
indexcurrent value
maxmaximum value
remainingmax - index
progressindex / max
percentprogress * 100
avgsimple moving average time per item (in seconds)
elapsedelapsed time in seconds
elapsed_tdelapsed as a timedelta (useful for printing as a string)
etaavg * remaining
eta_tdeta as a timedelta (useful for printing as a string)

Instead of passing all configuration options on instatiation, you can create your custom subclass:

classFancyBar(Bar):
message='Loading'fill='*'suffix='%(percent).1f%% - %(eta)ds'

You can also override any of the arguments or create your own:

classSlowBar(Bar):
suffix='%(remaining_hours)d hours remaining'@propertydefremaining_hours(self):
returnself.eta//3600

Spinners

For actions with an unknown number of steps you can use a spinner:

fromprogress.spinnerimportSpinnerspinner=Spinner('Loading ')
whilestate!='FINISHED':
# Do some workspinner.next()

There are 4 predefined spinners:

  • Spinner
  • PieSpinner
  • MoonSpinner
  • LineSpinner

Other

There are a number of other classes available too, please check the source or subclass one of them to create your own.

License

progress is licensed under ISC

About

Easy to use progress bars for Python

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages