Styled object

A Styled object contains a dictionary of styles.

It is mainly used for Table, RowView, ColView, and Cell.

class benker.styled.Styled(styles, nature)

Bases: object

Styled object, like Table, Row, Column, or Cell objects.

A styled object stores user-defined styles: a dictionary of key-value pairs. This values are useful to store some HTML-like styles (border-style, border-width, border-color, vertical-align, text-align, etc.). Of course, we are not tied to the HTML-like styles, you can use your own list of styles.

Note

The style dictionary is always copied: in other words, key-value pairs are copied but a shallow copy is done for the values (in general, it is not a problem if you use non-mutable values like str).

A styled object stores a nature: a way to distinguish the body cells, from the header and the footer. The default value is None, but you can use “body”, “header”, “footer” or whatever is suitable for your needs. This kind of information is in general not stored in the styles, even if it is similar.

Tables can also have a nature, similar to HTML @class attribute, you can use it do identify the styles to apply to your table.

Note

In a Grid, the merging of two natures is done by keeping the first nature and dropping the second one. In other words, the resulting nature is the group of the most top-left nature of the merged cells.

nature

Cell nature used to distinguish the body cells, from the header and the footer.

styles

Dictionary of key-value pairs, where keys are the style names.