summaryrefslogtreecommitdiffstats
path: root/docs/source/columns.rst
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:18:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:18:28 +0000
commitf8363b456f1ab31ee56abad579b215af195093d5 (patch)
treeb1500c675c2e0a55fb75721a854e1510acf7c862 /docs/source/columns.rst
parentInitial commit. (diff)
downloadrich-f8363b456f1ab31ee56abad579b215af195093d5.tar.xz
rich-f8363b456f1ab31ee56abad579b215af195093d5.zip
Adding upstream version 9.11.0.upstream/9.11.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--docs/source/columns.rst23
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/source/columns.rst b/docs/source/columns.rst
new file mode 100644
index 0000000..41a9bc6
--- /dev/null
+++ b/docs/source/columns.rst
@@ -0,0 +1,23 @@
+Columns
+=======
+
+Rich can render text or other Rich renderables in neat columns with the :class:`~rich.columns.Columns` class. To use, construct a Columns instance with an iterable of renderables and print it to the Console.
+
+The following example is a very basic clone of the ``ls`` command in OSX / Linux to list directory contents::
+
+ import os
+ import sys
+
+ from rich import print
+ from rich.columns import Columns
+
+ if len(sys.argv) < 2:
+ print("Usage: python columns.py DIRECTORY")
+ else:
+ directory = os.listdir(sys.argv[1])
+ columns = Columns(directory, equal=True, expand=True)
+ print(columns)
+
+
+See `columns.py <https://github.com/willmcgugan/rich/blob/master/examples/columns.py>`_ for an example which outputs columns containing more than just text.
+