Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a progress bar in a CLI application

When using tools like bzr, doxygen and scp or wget, I see that all of them have a nice progress bar that looks like this:

|=============>---------| 55% ETA 3:30

I tried writing something like that in C++ using the \b character as many times as I had written something out before. The output was flickering pretty badly and did not look nearly as smooth as the mentioned tools do.

How can I create such a progress bar (or at least change the displayed ETA) with Python smoothly?

like image 561
Martin Ueding Avatar asked Dec 09 '25 01:12

Martin Ueding


1 Answers

Use "\r" to send the cursor to the beginning of the line. Reprint no more than 2-3 times per second to avoid flickering.

like image 179
dkamins Avatar answered Dec 10 '25 15:12

dkamins