spinner readme

This commit is contained in:
Will McGugan 2020-12-13 12:32:23 +00:00
parent 12b268d223
commit 0c3294a121
2 changed files with 11 additions and 1 deletions

View File

@ -232,7 +232,7 @@ To try this out yourself, see [examples/downloader.py](https://github.com/willmc
## Status ## Status
For situations where it is hard to calculate progress, you can use the status method which will display a 'spinner' animation with a status message that won't prevent you from writing to the terminal. Here's an example: For situations where it is hard to calculate progress, you can use the [status](https://rich.readthedocs.io/en/latest/reference/status.html) method which will display a 'spinner' animation and message. The animation won't prevent you from using the console as normal. Here's an example:
```python ```python
from time import sleep from time import sleep
@ -252,6 +252,16 @@ This generates the following output in the terminal.
![status](https://github.com/willmcgugan/rich/raw/master/imgs/status.gif) ![status](https://github.com/willmcgugan/rich/raw/master/imgs/status.gif)
The spinner animations were borrowed from [cli-spinners])https://www.npmjs.com/package/cli-spinners). You can select a spinner by specifying the `spinner` parameter when calling status(). Run the following command to see the available values:
```
python -m rich.spinner
```
The above command generate the following output in the terminal:
![spinners](https://github.com/willmcgugan/rich/raw/master/imgs/spinners.gif)
## Columns ## Columns
Rich can render content in neat [columns](https://rich.readthedocs.io/en/latest/columns.html) with equal or optimal width. Here's a very basic clone of the (MacOS / Linux) `ls` command which displays a directory listing in columns: Rich can render content in neat [columns](https://rich.readthedocs.io/en/latest/columns.html) with equal or optimal width. Here's a very basic clone of the (MacOS / Linux) `ls` command which displays a directory listing in columns:

BIN
imgs/spinners.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB