Skip to content

Nested progress bars with different columns #950

Answered by ewels
ewels asked this question in Q&A
Discussion options

You must be logged in to vote

Ok great, I have it working! In the end it was super simple - I just overwrite self.columns within a custom Progress.get_renderables function depending on a task key. Simplified example:

class MyProgress(Progress):
    def get_renderables(self):
        for task in self.tasks:
            if task.fields.get("progress_type") == "mygreenbar":
                self.columns = ("[green]Rich is awesome!", BarColumn())
            if task.fields.get("progress_type") == "mybluebar":
                self.columns = (
                    "[blue]Another bar with a different layout",
                    BarColumn(bar_width=None),
                    "•",
                    DownloadColumn(),
          …

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ewels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants