rsalmei / alive-progress

A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
MIT License
5.45k stars 205 forks source link

Nester Bar not working #187

Closed t-abraham closed 2 years ago

t-abraham commented 2 years ago

I am trying to implement a nested progress bar where the description updates every iteration. According to my understanding, it was supposed to be 2 bars. Lets say the outer bar and then the inner bar. So as the inner bar reached 100% it fills up the outer bar progress a certain percentage and then goes again into the inner bar. However in my code, the output is getting completely messy with not proper output.

import time
from alive_progress import alive_bar

def start_loop1():
    with alive_bar(total=10, dual_line=True, title="Outer Loop") as pbar1:
        for i in range(10):
            # print ("\nworking on outer iteration - {}".format(i))
            pbar1.title("Outer Loop Iteration - {}".format(i))
            time.sleep(1)
            start_loop2()
            pbar1(1)

def start_loop2():
    with alive_bar(total=5, dual_line=True, title="Inner Loop") as pbar2:
        for i in range(5):
            # print ("\nworking on inner iteration - {}".format(i))
            pbar2.title("Inner Loop Iteration - {}".format(i))
            time.sleep(0.2)
            pbar2(1)

#%% Standalone Run

if __name__ == "__main__":
    start_loop1()

IPython 7.34.0 Python 3.9.12 Spyder 5.3.2 PyQt5 5.15.7 alive-progress 2.4.1

rsalmei commented 2 years ago

There isn't support for nested bars yet. Please, look for issues before opening new ones, this is already here in #20.