Skip to content

Latest commit

History

87 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Easy progress reporting for Python

pypi

Demo

Bars

There are 7 progress bars to choose from:

  • Bar
  • ChargingBar
  • FillingSquaresBar
  • FillingCirclesBar
  • IncrementalBar
  • PixelBar
  • 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()

or use any bar of this class as a context manager:

fromprogress.barimportBarwithBar('Processing', max=20) asbar:
foriinrange(20):
# Do some workbar.next()

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 instantiation, 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 5 predefined spinners:

  • Spinner
  • PieSpinner
  • MoonSpinner
  • LineSpinner
  • PixelSpinner

Installation

Download from PyPi

pip install progress

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

1.4k stars

Watchers

18 watching

Forks

Releases

Packages

Used by

Contributors

Languages