Re: Command Line Progress Bar

Discussion in 'Python' started by Mitya Sirenef, Dec 26, 2012.

  1. On 12/26/2012 01:17 AM, Kevin Anthony wrote:
    > Hello,
    > I'm writing a file processing script(Linux), and i would like to have
    > a progress bar. But i would also like to be able to print messages.
    > Is there a simple way of doing this without implementing something
    > like ncurses?
    >
    > --
    > Thanks
    > Kevin Anthony
    > www.NoSideRacing.com <http://www.NoSideRacing.com>



    Sure, you just need to print messages then the progress bar, without
    printing newline, then
    sys.stdout.flush(), then in the next loop start by printing '\r' to
    erase the progress bar.

    That is, if you want messages to scroll up. You can also use half a line
    for the progress
    bar and the other half for a short message, then you print both with
    sys.stdout.flush()
    and erase both with '\r'.

    - mitya


    --
    Lark's Tongue Guide to Python: http://lightbird.net/larks/
    Mitya Sirenef, Dec 26, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charlie Zhang
    Replies:
    3
    Views:
    1,238
    Paul Lutus
    Aug 16, 2004
  2. Rob

    progress bar or guage bar

    Rob, Jul 11, 2003, in forum: ASP General
    Replies:
    6
    Views:
    182
    Chris Barber
    Jul 12, 2003
  3. Irmen de Jong

    Re: Command Line Progress Bar

    Irmen de Jong, Dec 26, 2012, in forum: Python
    Replies:
    1
    Views:
    147
    Alec Taylor
    Dec 26, 2012
  4. xDog Walker

    Re: Command Line Progress Bar

    xDog Walker, Dec 26, 2012, in forum: Python
    Replies:
    0
    Views:
    149
    xDog Walker
    Dec 26, 2012
  5. Oscar Benjamin

    Re: Command Line Progress Bar

    Oscar Benjamin, Dec 27, 2012, in forum: Python
    Replies:
    0
    Views:
    145
    Oscar Benjamin
    Dec 27, 2012
Loading...

Share This Page