gws.lib.style¶
Feature styles.
A style describes how features are drawn: fill, stroke, markers, icons and labels.
Styles are written in a subset of CSS, extended with custom properties for markers and labels
(e.g. --marker, --label-fill). A leading -- is optional, and dashes in property names
are converted to underscores, so --label-fill becomes the label_fill value in gws.StyleValues.
Submodules:
core: theObjectclass implementinggws.Style, itsConfigandProps, and the constructorsfrom_dict,from_configandfrom_props.parser: parses CSS text or a dict of values into a dict of style values, validating property names and values and filling in defaults.icon: loads and parses SVG icons from data URLs, files or URLs.
Parsing depends on whether the source is trusted. Styles from the configuration are trusted and may load icons from arbitrary files and URLs. Styles from client requests are untrusted: icons are only accepted as data URLs or from the configured image directories. In strict mode, invalid properties and values raise an error, otherwise they are logged and skipped.
In style props sent to the client, a parsed icon is returned as a data URL. An icon that has not been parsed is not returned.
Example config:
style {
text "fill: rgba(255,0,0,0.4); stroke: red; stroke-width: 2; --label-fill: black"
}
Example:
import gws.lib.style
st = gws.lib.style.from_dict({'text': 'stroke: blue; stroke-width: 3px'})
st.values.stroke_width # 3
Source code: gws.lib.style