Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] Add expand Parameter to rich.progress.track for Full-Width Progress Bars #3588

Open
PeiPei233 opened this issue Dec 15, 2024 · 1 comment

Comments

@PeiPei233
Copy link

Have you checked the issues for a similar suggestions?
I have check the issue/discussion for similar suggestions.

How would you improve Rich?

Currently, the rich.progress.track function does not support the expand parameter. When used alongside other components with expand, it does not look visually consistent or unified. I want to modify the track function to include an expand parameter. When expand=True, it should add expand=True to the internal Progress instance and set the BarColumn's bar_width=None so that it displays in full width. The specific changes are as follows:

--- original progress.py                                                                                                                                      
                                                                                                                                                              
+++ new progress.py                                                                                                                                           
                                                                                                                                                              
@@ -122,6 +122,7 @@                                                                                                                                           
                                                                                                                                                              
     update_period: float = 0.1,                                                                                                                              
     disable: bool = False,                                                                                                                                   
     show_speed: bool = True,                                                                                                                                 
+    expand: bool = False,                                                                                                                                    
 ) -> Iterable[ProgressType]:                                                                                                                                 
     """Track progress by iterating over a sequence.                                                                                                          
                                                                                                                                                              
@@ -156,6 +157,7 @@                                                                                                                                           
                                                                                                                                                              
                 complete_style=complete_style,                                                                                                               
                 finished_style=finished_style,                                                                                                               
                 pulse_style=pulse_style,                                                                                                                     
+                bar_width=None if expand else 40,                                                                                                            
             ),                                                                                                                                               
             TaskProgressColumn(show_speed=show_speed),                                                                                                       
             TimeRemainingColumn(elapsed_when_finished=True),                                                                                                 
@@ -169,6 +171,7 @@                                                                                                                                           
                                                                                                                                                              
         get_time=get_time,                                                                                                                                   
         refresh_per_second=refresh_per_second or 10,                                                                                                         
         disable=disable,                                                                                                                                     
+        expand=expand,                                                                                                                                       
     )                                                                                                                                                        
                                                                                                                                                              
     with progress:   

Before expand:

image

After expand:

image
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant