Replies: 1 comment
|
You can keep a single The smallest customization is therefore at the column level, not by moving tasks between two from rich.text import Text
from rich.progress import SpinnerColumn, TimeElapsedColumn
class StartedSpinnerColumn(SpinnerColumn):
def render(self, task):
if not task.started:
return Text(" ")
return super().render(task)
class StartedElapsedColumn(TimeElapsedColumn):
def render(self, task):
if not task.started:
return Text(" ")
return super().render(task)Then: progress = Progress(
StartedSpinnerColumn(),
TextColumn("[progress.description]{task.description}"),
StartedElapsedColumn(),
)
task_id = progress.add_task("Waiting", start=False)
# later:
progress.start_task(task_id)That also naturally handles your permanently skipped rows: leave them unstarted and both status columns remain blank. I checked the current Rich implementation before suggesting this. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I've put together a simple task list for a layout sidebar in a project I'm working on. The idea is that the script is going to work its way down the list doing the tasks in series, and report details of its progress in another part of the layout.
The standard behaviour for a task with
start=Falseis for the spinner to animate. This seems like a potential source of confusion in my use case. Is there a way to change the behaviour?It would also be nice to be able to hide the empty timer (
-:--:--) until the task is started. I'd like this for the tasks mentioned above, but I'm also listing some items that will explicitly not be worked on. I didn't see a way to just add rows of arbitrary text in the list of tasks, so I'm including those with a grey description, and it would be nice to also hide the timer for those.Hiding the timer for both not-yet-started and will-not-start tasks would be nice, but not as important because I don't think it's as likely to be a point of confusion as the activated spinner on a task that hasn't been started.
Are there options I haven't found that will let me change either thing? Do I need to have two different Progress objects?
That still gives me the problem that I need to call
task_start()on tasks I don't plan to ever process (in order to set them immediately complete).Maybe someone has a suggestion for a better way accomplish what I'm attempting? The only other thing I can think of is to subclass Progress, SpinnerColumn, and TimeElapsedColumn to add a bunch of extra logic to them all.
All reactions