plesty.lib.ui.theme

Design tokens and stylesheet of the PLESTY shell.

Colours are data, not code: they live in assets/palette.json and the widget chrome lives in assets/shell.qss, whose {{token}} placeholders this module substitutes at load time. The tokens mirror the plesty.net theme (theme/static/css/plesty.css) and the canonical module/type colours, so the website, the generated reports, and the lab GUI stay one visual system — and a palette change never means editing Python.

theme = Theme.load()
app.setStyleSheet(theme.stylesheet())
pen_color = theme.color("cyan")          # trace colour by token
pen_color = theme.series_color(2)        # nth trace of a view

Attributes

ASSETS

_UNKNOWN

Classes

Theme

Resolved design tokens plus the stylesheet built from them.

Functions

_read_asset(→ str)

Return the text of a packaged asset.

Module Contents

plesty.lib.ui.theme.ASSETS = 'plesty.lib.ui.assets'
plesty.lib.ui.theme._UNKNOWN = '#ff00ff'
plesty.lib.ui.theme._read_asset(name: str) str

Return the text of a packaged asset.

Parameters:

name (str) – File name inside the assets directory.

Returns:

The file contents.

Return type:

str

class plesty.lib.ui.theme.Theme

Resolved design tokens plus the stylesheet built from them.

Variables:
  • name – Theme identifier, e.g. "plesty-dark".

  • tokens – Token name → hex colour.

  • series – Token names cycled for successive traces of a view.

  • colormap – Hex stops of the image/heatmap colour map, dark to bright.

  • state – Semantic state name → token name (running, idle, error, …).

name: str = 'plesty-dark'
tokens: dict[str, str]
series: list[str] = []
colormap: list[str] = []
state: dict[str, str]
classmethod load(palette: str | pathlib.Path | None = None) Theme

Load the packaged palette, or a custom one from disk.

Parameters:

palette (Optional[str | pathlib.Path]) – Path to a JSON palette with the same keys as the packaged palette.json; None loads the packaged one.

Returns:

The resolved theme.

Return type:

Theme

color(token: str, default: str | None = None) str

Return the hex colour of a design token.

Parameters:
  • token (str) – Token name ("cyan", "violet", "muted", …) or a literal #rrggbb value, which is passed through.

  • default (Optional[str]) – Returned when the token is unknown; without it an unknown token resolves to a glaring magenta rather than failing silently mid-experiment.

Returns:

The hex colour.

Return type:

str

series_color(index: int) str

Return the colour of the index-th trace of a view.

Parameters:

index (int) – Zero-based trace index; wraps around the series list.

Returns:

The hex colour.

Return type:

str

state_color(state: str) str

Return the colour marking a run or device state.

Parameters:

state (str) – State name, e.g. "running", "error", "idle".

Returns:

The hex colour; unknown states fall back to the muted text colour.

Return type:

str

stylesheet(source: str | pathlib.Path | None = None) str

Return the Qt stylesheet with every {{token}} substituted.

Parameters:

source (Optional[str | pathlib.Path]) – Path to a custom .qss template; None uses the packaged shell.qss.

Returns:

The rendered stylesheet.

Return type:

str