mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 18:18:22 +00:00
Turn "basic usage" progress example into a runnable example
This commit is contained in:
parent
e8a9466b94
commit
df775dabb5
1 changed files with 4 additions and 3 deletions
|
@ -19,12 +19,13 @@ To see how the progress display looks, try this from the command line::
|
|||
Basic Usage
|
||||
-----------
|
||||
|
||||
For basic usage call the :func:`~rich.progress.track` function, which accepts a sequence (such as a list or range object) and an optional description of the job you are working on. The track method will yield values from the sequence and update the progress information on each iteration. Here's an example::
|
||||
For basic usage call the :func:`~rich.progress.track` function, which accepts a sequence (such as a list or range object) and an optional description of the job you are working on. The track function will yield values from the sequence and update the progress information on each iteration. Here's an example::
|
||||
|
||||
import time
|
||||
from rich.progress import track
|
||||
|
||||
for n in track(range(n), description="Processing..."):
|
||||
do_work(n)
|
||||
for i in track(range(20), description="Processing..."):
|
||||
time.sleep(1) # Simulate work being done
|
||||
|
||||
Advanced usage
|
||||
--------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue