rsalmei / alive-progress

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

Pycharm doesn't show the bar #225

Closed dr-dark-flames closed 1 year ago

dr-dark-flames commented 1 year ago
def convert(path):
    output = r"\converted"
    if not os.path.exists(path + output):
        os.mkdir(path + output)

    for filename in os.listdir(path):
        if filename.endswith(".png") and filename[:-4] not in os.listdir(path + output):
            png_img = cv2.imread(os.path.join(path, filename))

            new_file = os.path.join(path + output, f'{filename.strip(".png")}.jpg')

            cv2.imwrite(new_file, png_img, [int(cv2.IMWRITE_JPEG_QUALITY), 100])

This is a simple function that I've been trying to add alive_bar to but never succeeded. Please help.

TheTechRobo commented 1 year ago

alive_bar isn't even used there. Please provide your full code or context.

dr-dark-flames commented 1 year ago
def convert(path):
    output = r"\converted"
    if not os.path.exists(path + output):
        os.mkdir(path + output)
    with alive_bar(0) as bar:
        for filename in os.listdir(path):
            if filename.endswith(".png") and filename[:-4] not in os.listdir(path + output):
                png_img = cv2.imread(os.path.join(path, filename))

                new_file = os.path.join(path + output, f'{filename.strip(".png")}.jpg')

                cv2.imwrite(new_file, png_img, [int(cv2.IMWRITE_JPEG_QUALITY), 100])
                time.sleep(0.0001)
            bar()
TheTechRobo commented 1 year ago

What problem are you having with it?

dr-dark-flames commented 1 year ago

What problem are you having with it?

Whenever I run the code the bar doesnt appear until the code is done and the bar appears finished and done.

TheTechRobo commented 1 year ago

What are you using to run the program? Jupyter Notebook, Pycharm, Windows terminal, Command Prompt,...?

dr-dark-flames commented 1 year ago

Pycharm

TheTechRobo commented 1 year ago

Does #173 answer your question?

rsalmei commented 1 year ago

Thanks @TheTechRobo! Yep, pycharm does not emulate a terminal by default, thus alive-progress cannot draw itself.

dr-dark-flames commented 1 year ago

I see, thanks a lot it worked!