[IPython-dev] Removing displayed javascript

Nathan Goldbaum nathan12343@gmail....
Tue Feb 11 18:21:02 CST 2014


Hi all,

Recently I've been making use of the very nice notebook-aware fork of
the python-progressbar library:

https://github.com/fnoble/python-progressbar

Inside a command-line session, this acts just like the original
python-progressbar library, displaying a nicely formatted ascii
progress bar. Inside of a notebook, it makes use of the display
protocal to create a nicely formatted animated HTML progressbar using
a bit of javascript to update the progressbar and clean up old
elements.

The library has already been patched so that the progressbar removes
all traces of itself from the cell display area after it has finished
up. However, I can't seem to find a way to also remove all traces of
the progress bar from the .ipynb json file.

Is it possible to dynamically remove displayed javascript from the
notebook .ipynb file?

Since python-progressbar uses a javascript callback invoked via
display() to update the progress bar, this means that there is a json
entry for each progress bar update and for the progress bar itself. In
a notebook with many progress bars, this means that the notebook file
can quickly balloon in size as it is filled up with repeats of the
same javascript cleanup code.

The cleanup could happen on the python side or on the javascript side,
whichever is more convenient.

Thanks for your advice,

Nathan Goldbaum


More information about the IPython-dev mailing list