Skip to content

Loading bar function written in python to use fira code's loading bar glyphs

License

Notifications You must be signed in to change notification settings

n1colassilva/fira-code-loading-bar

Repository files navigation

🇧🇷 version

Overview

This project provides a module for creating loading bars and spinners using fira code's special loading glyphs.

Fira code table of loading related dedicated glyphs

Loading bar

This project provides a function to generate loading bars:

generate_loading_bar(
    current_value = 50, # How much progress
    total_value = 100,  # Of how much
    bar_length = 100    # Optional, default is 100
    )

This code will generate you a nice loading bar: Example of the loading bar generated by the code For best results enable font ligatures

Usage

In case you are less experienced this is how you can make it update instead of printing a new line, this is an example for it in use

for i in range(1, 100000):

    print(f'\r{generate_loading_bar(i, 100000, 100)}', end='')

the \r is called a return carriage, it returns the "printing cursor" back to the start of the line, in case you don't get the name it's in reference to typewriters

in the end of a print the default is for python to add a newline (\n) at the end of a line, by overwriting that default and using the return carriage we can make the command line write a line, erase it and write again in the same line

Loading spinner

This project also provides a loading spinner so your loading bar doesnt get lonely.

For this one you don't really need to have ligatures on, but then why even use Fira Code?

Usage

The usage here is basically to give your iterator and how many iterations for the spinner to step into the next "frame"

for i in range(0, 100000):
    print(f'\r{generate_spinner(i, 2000)}', end='')
print("\rsuccess!")  # return carriage again to erase the spinner

About

Loading bar function written in python to use fira code's loading bar glyphs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages