Is there a way to directly access one of the fields in tasks.fields in a Progress Bar?
See original GitHub issueHi, first of all this library is really really great, thank you for the great work.
As for the subject of this post, I currently have a progress bar defined by:
progress_bar = Progress(
"[blue]{task.description}",
BarColumn(),
"[progress.percentage]{task.percentage:>3.0f}%",
TimeRemainingColumn(),
"[yellow]{task.fields}", # <-- relevant part
)
task = self.progress_bar.add_task(label, total=total_frames)
I am updating it with bar.update(self.task, advance=1, fps=f"{fps:.2f}")
and it runs just fine, with the progress bar displaying my fps as part of a dict, which would look something like {'fps': '6.60'}
at the end of the progress bar. This is a bit unsightly in my opinion, as I’d really prefer not to print it as a dict, with all its {
s and '
s. I would prefer to be able to chose exactly in what format my fields get printed in the progress bar.
Is there a way to chose exactly which field to show and with what format, without printing as a dict? I tried things like "[yellow]{task.fields.fps}fps"
or "[yellow]{task.fields['fps']}fps"
but it doesn’t work.
If this is not the case of me missing something obvious, it would be great to have this as a feature as it would allow us to chose how our custom fields look like.
Thanks for the awesome library by the way!
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Perfect, that fixed it, thanks a lot again! I don’t think I’ve ever seen a dev answer so quickly on such a large open source project, kudos!
PD: For anyone reading this issue, if you want ipdb or pdb to work with progress bars set:
in your
Progress()
constructor, and refresh your progress bar manually in yourupdate
method by settingrefresh=True
there.Both are writing to stdout, so it might be a problem.
Possibly the refresh thread is making it worse. Try setting auto_refresh=False for testing