I see, so with tqdm am I not able to create a single progress bar for each "for" loop in my code? today, I wrote this progress bar, it's a really simple function but, it works. let me know what do you think:
thanks to this progress bar I could see where my script is slow. probably i will open another topic to understand better how to improve that pice of code, and if it's possible also how to use more than one CPU with python.
import os import math from datetime import datetime, timezone # it can clear the terminal screen: def clear(): # for windows if os.name == 'nt': _ = os.system('cls') # for mac and linux(here, os.name is 'posix') else: _ = os.system('clear') # it can create a progress bar in the terminal: def progress_bar(header, current_time, number): remains = 60 - number percentage = str(math.ceil(100*number//60)) progress_bar = "\nLoading: [" + "#"*number + " "*remains + "]" clear() print(header, progress_bar, percentage + "% -", current_time + ",", datetime.utcnow().strftime('%H:%M:%S'))to use the "progress_bar" function you have to call it many times in the script. for example:
from datetime import datetime, timezone current_time = datetime.utcnow().strftime('%H:%M:%S') menu = "-------------------\nEXAMPLE\n-------------------\ntext..\n" progress_bar(menu, current_time, 0) # code .. # code .. progress_bar(menu, current_time, 4) # code .. # code .. progress_bar(menu, current_time, 8) # code .. # code .. # ....... progress_bar(menu, current_time, 60)I used this progress bar in my script and it works fine. you can see it in the attachments. unfortunately the percentuage shown by my progress bar is not the real percentuage, it depends by how many times did you use the function in the script and where, but it's ok, it doesn't matter. the main goal is to see the progress about my software.
thanks to this progress bar I could see where my script is slow. probably i will open another topic to understand better how to improve that pice of code, and if it's possible also how to use more than one CPU with python.