0

QUESTION: How can I make this progressbar to only print in the end of the command line so i can continue printing elsestuff in the console ?

I have made a progress bar, source code below:

def progressbar(percentage, info=''):

    if percentage > float(0.99):
        percentage = 1.0
    percent = 100 * percentage

    if percent > 2:
        percent /= 2

    percent = int(percent) + 1
    perstr = "█"
    for _ in range(percent):
        perstr += "█"

    print("%{:.2f} {}{:51.51}{} {:17.17}".format(percentage*100, "[", perstr, "]", info), end='\r')

And the result is this: %91.04 [███████████████████████████████████████████████ ] Info Section

* think of kali linux console progress bar *

  • 1
    I know this isn't direct answer to your question but consider using TQDM library, it will do progress bar for you ;) (https://pypi.org/project/tqdm/) – Damian Jan 27 '19 at 01:15
  • Shqipe, you have libraries you can install for this such as the one Damian mentioned, or [progress](https://pypi.org/project/progress/). You can also try some of the suggestions [here](https://stackoverflow.com/questions/3173320/text-progress-bar-in-the-console). – GKE Jan 27 '19 at 01:19
  • I already made a working progressbar , now i need to make it static somewhere ; first thing i wanted to try were ncurses for python but i couldn't make it happen , thats why i am here – Sport Shqiptar Jan 27 '19 at 01:40

0 Answers0