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

DoubleTable

DoubleTable uses box drawing characters for table borders. On Windows terminaltables uses code page 437 characters. However there is no equivalent character set for POSIX (Linux/OS X). Python automatically converts CP437 double-line box characters to Unicode and displays that instead.

_images/doubletable.png

Gaps on Windows 10

Like SingleTable 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.

Gaps on POSIX

There is no easy trick for POSIX like there is on Windows. I can’t seem to find out how to force terminals to eliminate gaps vertically between Unicode characters.

API

class terminaltables.DoubleTable(table_data, title=None)

Cross-platform table with box-drawing characters. On Windows it’s double borders, on Linux/OSX it’s unicode.

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.