gws.lib.style.core

Style object and constructors.

Source code: gws.lib.style.core

Module Contents

class gws.lib.style.core.Config(*args, **kwargs)

Bases: gws.Config

Feature style

cssSelector: str | None

CSS selector

text: str | None

raw style content

values: dict | None

style values

gws.lib.style.core.from_config(cfg: gws.Config, opts: gws.lib.style.parser.Options = None) → Object

Create a style object from a configuration.

Parameters:
  • cfg – Style configuration.

  • opts – Parser options. Defaults to trusted and strict.

Returns:

A style object.

Raises:

gws.Error – If a property or value is invalid and the parser is strict.

gws.lib.style.core.from_dict(d: dict, opts: gws.lib.style.parser.Options = None) → Object

Create a style object from a dict.

The dict can contain cssSelector, text (CSS text) and values (a dict of style values). Values from values override those parsed from text.

Parameters:
  • d – A dict with style properties.

  • opts – Parser options. Defaults to untrusted and strict.

Returns:

A style object.

Raises:

gws.Error – If a property or value is invalid and the parser is strict.

gws.lib.style.core.from_props(props: gws.Props, opts: gws.lib.style.parser.Options = None) → Object

Create a style object from client properties.

Parameters:
  • props – Style properties.

  • opts – Parser options. Defaults to untrusted and non-strict.

Returns:

A style object.

class gws.lib.style.core.Object(selector, text, values)

Bases: gws.Style

Style object.

cssSelector

CSS selector of the style.

text

Raw CSS text of the style.

values

Parsed style values.

props(user)
class gws.lib.style.core.Props(*args, **kwargs)

Bases: gws.Props

Object properties.

cssSelector: str | None

CSS selector

values: dict | None

Style values