5.4. Style¶
- class pytablewriter.style.Style(**kwargs: Any)[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.
fg_color (Union[
str
, tcolorpy.Color,None
]) – Alias tocolor
.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"
"typewriter"
(only for Latex writer)
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
- class pytablewriter.style.Align(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- AUTO = (1, 'auto')¶
- CENTER = (8, 'center')¶
- LEFT = (2, 'left')¶
- RIGHT = (4, 'right')¶
- property align_code: int¶
- property align_string: str¶
- class pytablewriter.style.DecorationLine(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- LINE_THROUGH = 'line_through'¶
- NONE = 'none'¶
- STRIKE = 'strike'¶
- UNDERLINE = 'underline'¶
- class pytablewriter.style.FontWeight(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- BOLD = 'bold'¶
- NORMAL = 'normal'¶
- class pytablewriter.style.FontSize(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- LARGE = 'large'¶
- MEDIUM = 'medium'¶
- NONE = 'none'¶
- SMALL = 'small'¶
- TINY = 'tiny'¶
- class pytablewriter.style.FontStyle(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- ITALIC = 'italic'¶
- NORMAL = 'normal'¶
- TYPEWRITER = 'typewriter'¶
- class pytablewriter.style.ThousandSeparator(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- 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, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
- BASELINE = (1, 'baseline')¶
- BOTTOM = (8, 'bottom')¶
- MIDDLE = (4, 'middle')¶
- TOP = (2, 'top')¶
- property align_code: int¶
- property align_str: str¶