How to use a newline in a progress bar? #921
-
Hi, I was trying to design a nice status update for multiple tasks running and I wanted to show a nice badge for each task (using a panel in a column) and in the line below, a spinner, some text and the progress bar. The problem is that I can't seem to figure out how to put the spinner, text and progress bar in a new line. Is this possible? If so, how? Code: result_columns = rich.columns.Columns()
rich.progress.Progress(
rich.progress.RenderableColumn(result_columns),
# I want a new line / line break here
rich.progress.SpinnerColumn(spinner_name='point'),
'[bold blue]{task.description}',
rich.progress.BarColumn(bar_width=80),
'[progress.percentage]{task.completed}/{task.total}',
) How it looks:
How I would like it to look:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
You will need to extend the Progress class for this. If you yield your results column from def get_renderables(self) -> Iterable[RenderableType]:
"""Get a number of renderables for the progress display."""
yield self.result_columns
table = self.make_tasks_table(self.tasks)
yield table |
Beta Was this translation helpful? Give feedback.
-
It works perfectly, thank you! Just one minor issue, mypy isn't happy about me subclassing
Do you know why this might be? |
Beta Was this translation helpful? Give feedback.
-
Couldn't say. Rich is fully typed. What happens if you do |
Beta Was this translation helpful? Give feedback.
-
Nevermind, I was running mypy with a different Python, which did not have access to the |
Beta Was this translation helpful? Give feedback.
You will need to extend the Progress class for this. If you yield your results column from
get_renderables
it will display them above the progress bar(s). Something like this: