Create visual loading screens in python

Asked

Viewed 1,152 times

-1

Like this:

|----- | 90%

Where it loads in the seconds I specify. For visual use only, because I want to make an aesthetic effect only :)

Where the lines are the loading bar ends and the dashes progress, where I want the bottom to display the completion percentage

  • 2

    Welcome to the Stack Overflow in English. A good practice to start a healthy discussion is to do the [tour], if you did, read the [Ask] guide. Start by following these recommendations, especially knowing what types of questions to ask, how to create a minimal example that is complete and verifiable, and even what to do when someone answers you.

  • In command interface (CLI) or really want windows?

1 answer

1

I used the character '#' instead of '-' which is the default, code below, run on a console to see the result, adapt the function test() for your context.

import time

def progress_bar(done):
    print("\rProgress: [{0:50s}] {1:.1f}%".format('#' * int(done * 50), done * 100),end='')

def test():
    for n in range(101):
        progress_bar(n/100)
        time.sleep(1)


test()      
Progress: [####################                             ] 20.0%

Browser other questions tagged

You are not signed in. Login or sign up in order to post.