Skip to content

Odd behavior where the progress bar deletes a printed line in terminal #254

@Ravencentric

Description

@Ravencentric
from pathlib import Path
from time import sleep

from alive_progress import alive_it, config_handler
config_handler.set_global(length=50, theme="classic", dual_line=True)

files = list(Path.cwd().glob("*"))
bar = alive_it(files, title="TEST")

print("this text will get deleted")

for file in bar:
    file_type = "Folder" if file.is_dir() else "File"
    bar.text(f"{file_type}: {file.name}")
    sleep(1)

6zM869N

If I remove bar.text(f"{file_type}: {file.name}"), then it works as expected:

9RFZMOG

If I remove file_type = "Folder" if file.is_dir() else "File", again it works:

DGZC6wz

From what I can gather, evaluating anything in file_type from the above example causes this. Getting rid of either this or bar.text fixes it at the cost of well not being able to do what I want. Same happens if I use any arbitrary function like:

from pathlib import Path
from time import sleep

from alive_progress import alive_it, config_handler

config_handler.set_global(length=50, theme="classic", dual_line=True)


def check(file: Path) -> int:
    if file.is_dir():
        return 1
    else:
        return 0


files = list(Path.cwd().glob("*"))
bar = alive_it(files, title="TEST")

print("this text will get deleted")


for file in bar:
    file_type = "Folder" if check(file) == 1 else "File"
    bar.text = f"{file_type}: {file.name}"
    sleep(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions