a title on top of progress bar #2930
Replies: 2 comments
-
You can customize get_renderable to include anything you like. |
Beta Was this translation helpful? Give feedback.
0 replies
-
thanks for the hint. I created a custom Progress class and achieved what I wanted. class TitledProgress(Progress):
def __init__(
self,
*columns: Union[str, ProgressColumn],
title = None,
console: Optional[Console] = None,
auto_refresh: bool = True,
refresh_per_second: float = 10,
speed_estimate_period: float = 30,
transient: bool = False,
redirect_stdout: bool = True,
redirect_stderr: bool = True,
get_time: Optional[GetTimeCallable] = None,
disable: bool = False,
expand: bool = False
) -> None:
self.title = title
super().__init__(
*columns,
console=console,
auto_refresh=auto_refresh,
refresh_per_second=refresh_per_second,
speed_estimate_period=speed_estimate_period,
transient=transient, redirect_stdout=redirect_stdout,
redirect_stderr=redirect_stderr,
get_time=get_time,
disable=disable,
expand=expand
)
def make_tasks_table(self, tasks: Iterable[Task]) -> Table:
table_columns = (
(
Column(no_wrap=True)
if isinstance(_column, str)
else _column.get_table_column().copy()
)
for _column in self.columns
)
table = Table.grid(*table_columns, padding=(0, 1), expand=self.expand)
if self.title is not None:
table.add_row(self.title)
for task in tasks:
if task.visible:
table.add_row(
*(
(
column.format(task=task)
if isinstance(column, str)
else column(task)
)
for column in self.columns
)
)
return table |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was wondering if there's a way to have a row (without progress bar) on top of a Progress. What I want to achieve is to have the title of the task on top so that I don't include it in the description of the task and occupy the width of the console unnecessarily.
e.g.,
instead of
"task_description" + "some info" + progress_bar + completed_percentage + "remaining_time"
I want to have:
"some info"
"task_description" + progress_bar + completed_percentage + remaining_time
Beta Was this translation helpful? Give feedback.
All reactions