mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 01:58:24 +00:00
docs
This commit is contained in:
parent
05361888f0
commit
dcbd70bbbb
3 changed files with 27 additions and 0 deletions
|
@ -44,6 +44,12 @@ Here's a simple example::
|
|||
progress.update(task3, advance=0.9)
|
||||
time.sleep(0.02)
|
||||
|
||||
Starting Tasks
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
When you add a task it is automatically *started* which means it will show a progress bar at 0% and the time remaining will be calculated from the current time. Occasionally this may not work well if there is a long delay before you can start updating progress, you may need to wait for a response from a server, or count files in a directory (for example) before you can begin tracking progress. In these cases you can call :meth:`~rich.progress.Progress.add_task` with ``start=False`` which will display the a pulsing animation that lets the user know something is working. When you have the number of steps you can call :meth:`~rich.progress.Progress.start_task` which will display the progress bar at 0%, then :meth:`~rich.progress.Progress.update` as normal.
|
||||
|
||||
|
||||
Updating Tasks
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
@ -50,3 +50,23 @@ You can set the border style by importing one of the preset :class:`~rich.box.Bo
|
|||
See :ref:`appendix_box` for other box styles.
|
||||
|
||||
The :class:`~rich.table.Table` class offers a number of configuration options to set the look and feel of the table, including how borders are rendered and the style and alignment of the columns.
|
||||
|
||||
|
||||
Adding columns
|
||||
~~~~~~~~~~~~~~
|
||||
|
||||
You may also add columns by specifying them in the positional arguments of the :class:`~rich.table.Table` constructor. For example, we could construct a table with three columns like this::
|
||||
|
||||
table = Table("Released", "Title", "Box Office", title="Star Wars Movies")
|
||||
|
||||
This allows you to specify the text of the column only. If you want to set other attributes, such as width, style, and alignment, you can add an :class:`~rich.table.Column` class. Here's an example::
|
||||
|
||||
from rich.table import Column
|
||||
table = Table(
|
||||
"Released",
|
||||
"Title",
|
||||
Column("Box Office", align="right"),
|
||||
title="Star Wars Movies"
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue