fnoble/python-progressbar — pull request #3 by sboeser (2013-08-24 15:36:58+00:00)
Title: Bugfix and cleanup of outputs

Dear Fergus,

thanks very much for this nice IPython notebook adaption. Unfortunately, I found two slight problems when running multiple ProgressBars in the same cell, such as this one

#Run serveral progressbars in the same output cell...
from progressbar import ProgressBar
from IPython.display import HTML,Javascript
import time
pBar = ProgressBar()
for i in range(0,3):
display(HTML("
Try number %s"%i))
display(Javascript('console.log("Number of outputs",this.outputs.length);'))
print "test"
for x in pBar(range(0,100)):
time.sleep(0.002)

* Only in the first ProgressBar the bar itself would be updated. In the other ProgressBars, only the Percentage would update.

* If running a lot of ProgressBars, a piece of JavaScript will stick in the Output cell for every update. This will not only bloat the notebook on save, but also show up as a useless piece of text when reloading the notebook.

So, I've added some code that cleans up (nearly) all of the elements in the output area from the ProgressBar once its finished.

Sebastian