5.4. Style

class pytablewriter.style.Style(**kwargs)[source]

Style specifier class for table elements.

Parameters
  • color (Union[str, tcolorpy.Color, None]) –

    Text color for cells. When using str, specify a color code ("#XXXXXX") or a color name.

    Note

    In the current version, only applicable for part of text format writer classes.

  • bg_color (Union[str, tcolorpy.Color, None]) –

    background color for cells. When using str, specify a color code ("#XXXXXX") or a color name.

    Note

    In the current version, only applicable for part of text format writer classes.

  • align (str / Align) –

    Horizontal text alignment for cells. This can be only applied for text format writer classes. Possible string values are:

    • "auto" (default)
      • Detect data type for each column and set alignment that appropriate for the type automatically

    • "left"

    • "right"

    • "center"

  • vertical_align (str / VerticalAlign) –

    Vertical text alignment for cells. This can be only applied for HtmlTableWriter class. Possible string values are:

    • "baseline" (default)

    • "top"

    • "middle"

    • "bottom"

  • font_size (str / FontSize) –

    Font size specification for cells in a column. This can be only applied for HTML/Latex writer classes. Possible string values are:

    • "tiny"

    • "small"

    • "medium"

    • "large"

    • "none" (default: no font size specification)

  • font_weight (str / FontWeight) –

    Font weight specification for cells in a column. This can be only applied for HTML/Latex/Markdown writer classes. Possible string values are:

    • "normal" (default)

    • "bold"

  • font_style (str / FontStyle) –

    Font style specification for cells in a column. This can be applied only for HTML/Latex/Markdown writer classes. Possible string values are:

    • "normal" (default)

    • "italic"

  • decoration_line (str / DecorationLine) –

    Experiental. Possible string values are:

    • "line-through"

    • "strike" (alias for "line-through")

    • "underline"

    • "none" (default)

  • thousand_separator (str / ThousandSeparator) –

    Thousand separator specification for numbers in a column. This can be only applied for text format writer classes. Possible string values are:

    • ","/"comma"

    • " "/"space"

    • "_"/"underscore"

    • ""/"none" (default)

Example

Specify Cell Styles For Each Column

update(**kwargs)None[source]

Update specified style attributes.

class pytablewriter.style.Align(value)[source]

An enumeration.

AUTO = (1, 'auto')
CENTER = (8, 'center')
LEFT = (2, 'left')
RIGHT = (4, 'right')
property align_code
property align_string
class pytablewriter.style.DecorationLine(value)[source]

An enumeration.

LINE_THROUGH = 'line_through'
NONE = 'none'
STRIKE = 'strike'
UNDERLINE = 'underline'
class pytablewriter.style.FontWeight(value)[source]

An enumeration.

BOLD = 'bold'
NORMAL = 'normal'
class pytablewriter.style.FontSize(value)[source]

An enumeration.

LARGE = 'large'
MEDIUM = 'medium'
NONE = 'none'
SMALL = 'small'
TINY = 'tiny'
class pytablewriter.style.FontStyle(value)[source]

An enumeration.

ITALIC = 'italic'
NORMAL = 'normal'
class pytablewriter.style.ThousandSeparator(value)[source]

An enumeration.

COMMA = 'comma'

',' as thousands separator

NONE = 'none'

no thousands separator

SPACE = 'space'

' ' as thousands separator

UNDERSCORE = 'underscore'

'_' as thousands separator

class pytablewriter.style.VerticalAlign(value)[source]

An enumeration.

BASELINE = (1, 'baseline')
BOTTOM = (8, 'bottom')
MIDDLE = (4, 'middle')
TOP = (2, 'top')
property align_code
property align_str
class pytablewriter.style.Cell(row: int, col: int, value: Any, default_style: pytablewriter.style._style.Style)[source]
row: int

row index.

col: int

column index.

value: Any

data for the cell.

default_style: pytablewriter.style.Style

default Style for the cell.

is_header_row()bool[source]

Return True if the cell is a header.