Last active
March 24, 2024 21:07
-
-
Save PeterWaIIace/2db7f04440f768b716511726d4a343f5 to your computer and use it in GitHub Desktop.
Nice progress bar for python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
class bcolors: | |
HEADER = '\033[95m' | |
OKBLUE = '\033[94m' | |
OKCYAN = '\033[96m' | |
OKGREEN = '\033[92m' | |
WARNING = '\033[93m' | |
FAIL = '\033[91m' | |
ENDC = '\033[0m' | |
BOLD = '\033[1m' | |
UNDERLINE = '\033[4m' | |
start_timestamp = time.time() | |
def printProgress(percentage): | |
global progress_timestamp | |
val = int(percentage * 100) | |
symbol = '━' | |
lpad = ''.join([symbol for v in range(val)]) | |
rpad = ''.join([symbol for v in range(100 - val)]) | |
tps = val/(time.time() - start_timestamp) | |
print("\rProgress: |"+bcolors.OKGREEN+f"{lpad}"+bcolors.ENDC+bcolors.OKBLUE+f"{rpad}"+bcolors.ENDC+f"| {val}% | {tps:.2f} T/s", end='',flush=True) | |
if(val >= 100): | |
print("") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment