Warning: This document is for the development version of terminaltables. The latest version is v3.1.0.

SingleTable

SingleTable uses box drawing characters for table borders. On POSIX (Linux/OS X) terminaltables uses Esc ( 0 characters while on Windows it uses code page 437 characters.

_images/singletable.png

Gaps on Windows 10

Unfortunately the console on Windows 10 changed the default font face to Consolas. This new font seems to show gaps between lines. Switching the font back to Lucida Console eliminates the gaps.

API

class terminaltables.SingleTable(table_data, title=None)

Cross-platform table with single-line box-drawing characters.

Variables:
  • table_data (iter) – List (empty or list of lists of strings) representing the table.
  • title (str) – Optional title to show within the top border of the table.
  • inner_column_border (bool) – Separates columns.
  • inner_footing_row_border (bool) – Show a border before the last row.
  • inner_heading_row_border (bool) – Show a border after the first row.
  • inner_row_border (bool) – Show a border in between every row.
  • outer_border (bool) – Show the top, left, right, and bottom border.
  • justify_columns (dict) – Horizontal justification. Keys are column indexes (int). Values are right/left/center.
  • padding_left (int) – Number of spaces to pad on the left side of every cell.
  • padding_right (int) – Number of spaces to pad on the right side of every cell.
column_max_width(column_number)

Return the maximum width of a column based on the current terminal width.

Parameters:column_number (int) – The column number to query.
Returns:The max width of the column.
Return type:int
column_widths

Return a list of integers representing the widths of each table column without padding.

ok

Return True if the table fits within the terminal width, False if the table breaks.

table

Return a large string of the entire table ready to be printed to the terminal.

table_width

Return the width of the table including padding and borders.