Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Handling progress bars as objects #11

Closed
sjmikler opened this issue Feb 29, 2024 · 1 comment
Closed

[FEATURE] Handling progress bars as objects #11

sjmikler opened this issue Feb 29, 2024 · 1 comment

Comments

@sjmikler
Copy link
Owner

It would be nice to be able to treat progress bars as objects and update them manually.

This is available in tqdm:

pbar = tqdm(total=100)
for i in range(10):
    sleep(0.1)
    pbar.update(10)
pbar.close()

The suggestion is to have the equivalent in progress-table:

pbar = table.pbar(total=100)
for i in range(10):
    sleep(0.1)
    pbar.update(10)
pbar.close()
@sjmikler
Copy link
Owner Author

sjmikler commented Mar 1, 2024

This feature was added in version 1.2:

import time
import random
from progress_table import ProgressTableV1

table = ProgressTableV1()

total = 0
target = 1000
pbar = table.pbar(1000)

while total < target:
    new_value = random.randint(0, 100)
    total += new_value

    table["random int"] = new_value
    table["random float"] = random.random()
    table["current total"] = total

    pbar.update(new_value)
    table.next_row()
    time.sleep(0.1)
table.close()

@sjmikler sjmikler closed this as completed Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant