On 07Nov2018 11:22, Chip Wachob <wach...@gmail.com> wrote:
I'm sure that this is simple and my searches have just not used the
correct words.

What I would like to do is display, on a single line, in the terminal
/ command line a progress percentage, or, simply a sequence of - / -
\, etc.. or even, accumulating period characters.

What would the escape codes be, or is there a better way to handle this?

Note that I need this to be platform agnostic.

I'e got a module 'cs.upd' on PyPI which does this. "pip install cs.upd" to obtain it.

Typical usage:

 import sys
 import time
 from cs.upd import Upd

 upd = Upd(sys.stdout)
 for percentage in range(1,100):
   upd.out("Progress: %d%%", percentage)
   if percentage % 10 == 0:
     upd.nl("completed %d%%", percentage)
   time.sleep(0.1)
 upd.out("Complete!")
 time.sleep(1.0)

That example is obviously contrived, and the sleeps are so you can see it all happen. But you can slot this into simple terminal based programmes to present dynamic progress.

Cheers,
Cameron Simpson <c...@cskk.id.au>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to