[IPython-User] carriage return in ipython notebook?

MinRK benjaminrk@gmail....
Mon Apr 9 17:24:59 CDT 2012


On Mon, Apr 9, 2012 at 14:46, mqk <kuhlen@gmail.com> wrote:

> Hi MinRK
>
> Thanks for your response. I did come across your working example, but I
> don't like it. :) The repeated clearing of the output results in a
> strobe-like appearance for me, and of course it also erases any previous
> output that is unrelated to the progress bar. Oh well.
>

The strobe complaint is common, and actually fixed in an outstanding
PR<https://github.com/ipython/ipython/pull/1563>.
 You can selectively clear stdout/stderr/pyout, but not subsets of each of
those.  That said, if you want the notebook to be a terminal emulator, you
don't actually want the notebook.  For instance, a more natural progress
bar for the notebook would just be written in Javascript.

Here's one I just wrote based on a quick Googling of 'javascript progress
bar' since receiving your email:

import uuid
from IPython.core.display import HTML, Javascript, display

divid = str(uuid.uuid4())

display(HTML(
"""
<div style="border: 1px solid black; width:500px">
  <div id="%s" style="background-color:blue; width:0%%">&nbsp;</div>
</div>
""" % divid)
)

for i in range(1,101):
    time.sleep(0.1)
    display(Javascript("$('div#%s').width('%i%%')" % (divid, i)))

It does require using my `clear_output` branch, pending as PR
#1563<https://github.com/ipython/ipython/pull/1563>,
to avoid some ugliness.

-MinRK


>
> --
> View this message in context:
> http://python.6.n6.nabble.com/carriage-return-in-ipython-notebook-tp4717456p4717493.html
> Sent from the IPython - User mailing list archive at Nabble.com.
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20120409/e99a3be0/attachment.html 


More information about the IPython-User mailing list