rich/docs/source/appendix/box.rst

80 lines
14 KiB
ReStructuredText
Raw Normal View History

2020-01-12 15:54:47 +00:00
.. _appendix_box:
2020-01-11 16:13:39 +00:00
Box
===
2020-06-27 21:18:30 +00:00
Rich has a number of constants that set the box characters used to draw tables and panels. To select a box style import one of the constants below from ``rich.box``. For example::
2020-01-12 15:54:47 +00:00
from rich import box
table = Table(box=box.SQUARE)
2020-06-27 21:16:00 +00:00
.. note::
Some of the box drawing characters will not display correctly on Windows legacy terminal (cmd.exe) with *raster* fonts, and are disabled by default. If you want the full range of box options on Windows legacy terminal, use a *truetype* font and set the ``safe_box`` parameter on the Table class to ``False``.
2020-06-28 16:54:43 +00:00
The following table is generated with this command::
2020-06-27 21:16:00 +00:00
python -m rich.box
2020-01-11 16:13:39 +00:00
.. raw:: html
2020-06-28 16:57:27 +00:00
<pre style="font-size:90%;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace"><span style="color: #008000">╭──────────────────────────────────────────────────────────────────────────────╮</span>
2020-06-28 16:53:43 +00:00
<span style="color: #008000">│</span> <span style="color: #008000; font-weight: bold">Box Constants</span> <span style="color: #008000">│
╰──────────────────────────────────────────────────────────────────────────────╯</span>
2020-06-27 21:16:00 +00:00
2020-06-28 16:53:43 +00:00
<span style="color: #800080"> box.ASCII </span> <span style="color: #800080"> box.SQUARE </span> <span style="color: #800080"> box.MINIMAL </span>
+------------------------+ ┌────────────┬───────────┐
|<span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>|<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span>| │<span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span>│ <span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span>
|------------+-----------| ├────────────┼───────────┤ ───────────┼──────────
|<span style="color: #7f7f7f"> Cell </span>|<span style="color: #7f7f7f"> Cell </span>| │<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>│ <span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>
|<span style="color: #7f7f7f"> Cell </span>|<span style="color: #7f7f7f"> Cell </span>| │<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>│ <span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>
|------------+-----------| ├────────────┼───────────┤ ───────────┼──────────
|<span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>|<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span>| │<span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span>│ <span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span>
+------------------------+ └────────────┴───────────┘
<span style="color: #800080"> box.MINIMAL_HEAVY_HEAD </span> <span style="color: #800080"> box.MINIMAL_DOUBLE_HEAD </span> <span style="color: #800080"> box.SIMPLE </span>
<span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span> <span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span> <span style="color: #7f7f7f; font-weight: bold"> Header 1 </span> <span style="color: #7f7f7f; font-weight: bold"> Header 2 </span>
━━━━━━━━━━━━┿━━━━━━━━━━━ ════════════╪═══════════ ────────────────────────
<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span>
<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span>
────────────┼─────────── ────────────┼─────────── ────────────────────────
<span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span> <span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span> <span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span> <span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span>
<span style="color: #800080"> box.SIMPLE_HEAVY </span> <span style="color: #800080"> box.HORIZONTALS </span> <span style="color: #800080"> box.ROUNDED </span>
────────────────────────── ╭───────────┬──────────╮
<span style="color: #7f7f7f; font-weight: bold"> Header 1 </span> <span style="color: #7f7f7f; font-weight: bold"> Header 2 </span> <span style="color: #7f7f7f; font-weight: bold"> Header 1 </span> <span style="color: #7f7f7f; font-weight: bold"> Header 2 </span> │<span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span>│
╺━━━━━━━━━━━━━━━━━━━━━━━━╸ ────────────────────────── ├───────────┼──────────┤
<span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span> │<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>│
<span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span> <span style="color: #7f7f7f"> Cell </span> │<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>│
╺━━━━━━━━━━━━━━━━━━━━━━━━╸ ────────────────────────── ├───────────┼──────────┤
<span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span> <span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span> <span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span> <span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span> │<span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span>│
────────────────────────── ╰───────────┴──────────╯
<span style="color: #800080"> box.HEAVY </span> <span style="color: #800080"> box.HEAVY_EDGE </span> <span style="color: #800080"> box.HEAVY_HEAD </span>
┏━━━━━━━━━━━━┳━━━━━━━━━━━┓ ┏━━━━━━━━━━━━┯━━━━━━━━━━━┓ ┏━━━━━━━━━━━┳━━━━━━━━━━┓
┃<span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>┃<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span>┃ ┃<span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span>┃ ┃<span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>┃<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span>┃
┣━━━━━━━━━━━━╋━━━━━━━━━━━┫ ┠────────────┼───────────┨ ┡━━━━━━━━━━━╇━━━━━━━━━━┩
┃<span style="color: #7f7f7f"> Cell </span>┃<span style="color: #7f7f7f"> Cell </span>┃ ┃<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>┃ │<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>│
┃<span style="color: #7f7f7f"> Cell </span>┃<span style="color: #7f7f7f"> Cell </span>┃ ┃<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>┃ │<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>│
┣━━━━━━━━━━━━╋━━━━━━━━━━━┫ ┠────────────┼───────────┨ ├───────────┼──────────┤
┃<span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>┃<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span>┃ ┃<span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span>┃ │<span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span>│
┗━━━━━━━━━━━━┻━━━━━━━━━━━┛ ┗━━━━━━━━━━━━┷━━━━━━━━━━━┛ └───────────┴──────────┘
<span style="color: #800080"> box.DOUBLE </span> <span style="color: #800080"> box.DOUBLE_EDGE </span>
╔════════════╦═══════════╗ ╔════════════╤═══════════╗
║<span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>║<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span>║ ║<span style="color: #7f7f7f; font-weight: bold"> Header 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Header 2 </span>║
╠════════════╬═══════════╣ ╟────────────┼───────────╢
║<span style="color: #7f7f7f"> Cell </span>║<span style="color: #7f7f7f"> Cell </span>║ ║<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>║
║<span style="color: #7f7f7f"> Cell </span>║<span style="color: #7f7f7f"> Cell </span>║ ║<span style="color: #7f7f7f"> Cell </span>│<span style="color: #7f7f7f"> Cell </span>║
╠════════════╬═══════════╣ ╟────────────┼───────────╢
║<span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>║<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span>║ ║<span style="color: #7f7f7f; font-weight: bold"> Footer 1 </span>│<span style="color: #7f7f7f; font-weight: bold"> Footer 2 </span>║
╚════════════╩═══════════╝ ╚════════════╧═══════════╝
</pre>