MCPcopy
hub / github.com/Textualize/rich / Table

Class Table

rich/table.py:153–935  ·  view source on GitHub ↗

A console renderable to draw a table. Args: *headers (Union[Column, str]): Column headers, either as a string, or :class:`~rich.table.Column` instance. title (Union[str, Text], optional): The title of the table rendered at the top. Defaults to None. caption (Union[str, T

Source from the content-addressed store, hash-verified

151
152
153class Table(JupyterMixin):
154 """A console renderable to draw a table.
155
156 Args:
157 *headers (Union[Column, str]): Column headers, either as a string, or :class:`~rich.table.Column` instance.
158 title (Union[str, Text], optional): The title of the table rendered at the top. Defaults to None.
159 caption (Union[str, Text], optional): The table caption rendered below. Defaults to None.
160 width (int, optional): The width in characters of the table, or ``None`` to automatically fit. Defaults to None.
161 min_width (Optional[int], optional): The minimum width of the table, or ``None`` for no minimum. Defaults to None.
162 box (box.Box, optional): One of the constants in box.py used to draw the edges (see :ref:`appendix_box`), or ``None`` for no box lines. Defaults to box.HEAVY_HEAD.
163 safe_box (Optional[bool], optional): Disable box characters that don't display on windows legacy terminal with *raster* fonts. Defaults to True.
164 padding (PaddingDimensions, optional): Padding for cells (top, right, bottom, left). Defaults to (0, 1).
165 collapse_padding (bool, optional): Enable collapsing of padding around cells. Defaults to False.
166 pad_edge (bool, optional): Enable padding of edge cells. Defaults to True.
167 expand (bool, optional): Expand the table to fit the available space if ``True``, otherwise the table width will be auto-calculated. Defaults to False.
168 show_header (bool, optional): Show a header row. Defaults to True.
169 show_footer (bool, optional): Show a footer row. Defaults to False.
170 show_edge (bool, optional): Draw a box around the outside of the table. Defaults to True.
171 show_lines (bool, optional): Draw lines between every row. Defaults to False.
172 leading (int, optional): Number of blank lines between rows (precludes ``show_lines``). Defaults to 0.
173 style (Union[str, Style], optional): Default style for the table. Defaults to "none".
174 row_styles (List[Union, str], optional): Optional list of row styles, if more than one style is given then the styles will alternate. Defaults to None.
175 header_style (Union[str, Style], optional): Style of the header. Defaults to "table.header".
176 footer_style (Union[str, Style], optional): Style of the footer. Defaults to "table.footer".
177 border_style (Union[str, Style], optional): Style of the border. Defaults to None.
178 title_style (Union[str, Style], optional): Style of the title. Defaults to None.
179 caption_style (Union[str, Style], optional): Style of the caption. Defaults to None.
180 title_justify (str, optional): Justify method for title. Defaults to "center".
181 caption_justify (str, optional): Justify method for caption. Defaults to "center".
182 highlight (bool, optional): Highlight cell contents (if str). Defaults to False.
183 """
184
185 columns: List[Column]
186 rows: List[Row]
187
188 def __init__(
189 self,
190 *headers: Union[Column, str],
191 title: Optional[TextType] = None,
192 caption: Optional[TextType] = None,
193 width: Optional[int] = None,
194 min_width: Optional[int] = None,
195 box: Optional[box.Box] = box.HEAVY_HEAD,
196 safe_box: Optional[bool] = None,
197 padding: PaddingDimensions = (0, 1),
198 collapse_padding: bool = False,
199 pad_edge: bool = True,
200 expand: bool = False,
201 show_header: bool = True,
202 show_footer: bool = False,
203 show_edge: bool = True,
204 show_lines: bool = False,
205 leading: int = 0,
206 style: StyleType = "none",
207 row_styles: Optional[Iterable[StyleType]] = None,
208 header_style: Optional[StyleType] = "table.header",
209 footer_style: Optional[StyleType] = "table.footer",
210 border_style: Optional[StyleType] = None,

Callers 15

render_tablesFunction · 0.90
test_not_renderableFunction · 0.90
test_init_append_columnFunction · 0.90
test_rich_measureFunction · 0.90
test_min_widthFunction · 0.90
test_no_columnsFunction · 0.90
test_get_row_styleFunction · 0.90
make_tableFunction · 0.90
test_sectionFunction · 0.90

Calls

no outgoing calls

Tested by 15

render_tablesFunction · 0.72
test_not_renderableFunction · 0.72
test_init_append_columnFunction · 0.72
test_rich_measureFunction · 0.72
test_min_widthFunction · 0.72
test_no_columnsFunction · 0.72
test_get_row_styleFunction · 0.72
make_tableFunction · 0.72
test_sectionFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…