Themes¶
The editor ships with three themes: purple-synthwave (the default: a near-black
canvas with blue-violet cards, made from a Coolors palette), antimony (dark)
and antimony-light. Pick one by name in Python, or in the page: the menu button
at the top right has Select theme, which switches at once (a reload brings back
the theme Python holds). In Python:
element_51.serve(app, theme="antimony-light")
Your own theme¶
A theme file is a JSON file that lists only the values you want to change. The rest come from a built-in theme. Pass its path instead of a name:
element_51.serve(app, theme="my_theme.json")
{
"base": "antimony",
"colours": {"canvas": "#101820"},
"ports": {"float": {"out": {"colour": "#ffb000", "shape": "circle"}}},
"metrics": {"node_width": 260},
"fonts": {
"value": "13px Menlo, monospace",
"value_family": "Menlo, monospace"
}
}
The file has six members, all optional:
Member |
Meaning |
|---|---|
|
The built-in theme to start from: |
|
Colours to replace, by key. |
|
The colour and shape of port markers, by type and side. |
|
Sizes on the canvas to replace, by key. |
|
Sizes of the menus, the Run button and the other page parts, by key. |
|
Fonts to replace, by key. |
examples/e_look/e2_theme_file.py and examples/my_theme.json are a working pair.
The same choice works on a running app: app.theme = "my_theme.json" redraws
every open page.
What goes wrong¶
A path that is not a file, a file that is not JSON, a member other than the four above, a colour that is not text, or a size that is not a number makes
serveraiseValueErrorbefore anything starts.A key that does not exist (
"canvass") cannot be checked in Python, because the keys live in the browser’s code. The page shows a banner that names the section and the key and lists the valid keys, and it keeps the previous theme.A value of the right kind but a bad content, such as
"colours": {"canvas": "banana"}or a font that is not installed, is handled by the browser: an invalid colour is ignored and a missing font falls back to the next family in the list.
Every key you can change¶
Each table shows the key, what it affects and the built-in values. The tables list every key, so a theme file never needs one that is not here.
colours¶
Any CSS colour: "#1a1a1a", "rgb(26, 26, 26)", "rgba(0, 0, 0, 0.5)" or a name such as "tomato".
Key |
What it colours |
|
|
|
|---|---|---|---|---|
|
The canvas behind the graph. |
|
|
|
|
The dots of the grid on the canvas. |
|
|
|
|
A node card’s body. |
|
|
|
|
The line round a node card. |
|
|
|
|
A node card’s title bar. |
|
|
|
|
The title bar of a node that failed. |
|
|
|
|
The line round a node card whose last run failed. |
|
|
|
|
The title bar of a node that was skipped. |
|
|
|
|
The id and type name in a title bar. |
|
|
|
|
Port names, and the values shown after a run. |
|
|
|
|
Faded text, for a node that was skipped. |
|
|
|
|
A greyed hint in a value box: a default, a source, |
|
|
|
|
The three-bar icon in a title bar. |
|
|
|
|
The outline of a selected node. |
|
|
|
|
A selected wire, which must show on the canvas. |
|
|
|
|
A port a dragged link may end at. |
|
|
|
|
A port a dragged link may not end at. |
|
|
|
|
The background of a value box. |
|
|
|
|
Text typed in a value box. |
|
|
|
|
The border of an input box. |
|
|
|
|
The right-click menu’s background. |
|
|
|
|
Text in the right-click menu. |
|
|
|
|
Muted text in the right-click menu, such as |
|
|
|
|
The line round the right-click menu, its flyouts and its search box. |
|
|
|
|
The search box in the right-click menu. |
|
|
|
|
The shadow under the right-click menu. |
|
|
|
|
The menu entry under the pointer. |
|
|
|
|
Text of the menu entry under the pointer. |
|
|
|
|
A Python keyword ( |
|
|
|
|
A string, docstrings included, in the source panel. |
|
|
|
|
A comment in the source panel. |
|
|
|
|
A number in the source panel. |
|
|
|
|
A decorator, or the name after |
|
|
|
|
The Run button’s background. |
|
|
|
|
The Run button’s text and triangle. |
|
|
|
|
The line round the Run button. |
|
|
|
|
The Run button’s background under the pointer. |
|
|
|
|
The Run button’s text under the pointer. |
|
|
|
|
The ring round the control that has the keyboard focus. |
|
|
|
|
The tint of a ticked checkbox in a value box. |
|
|
|
|
The error banner’s background. |
|
|
|
|
Text in the error banner. |
|
|
|
ports¶
Each port type has an in style for its inputs and an out style for its outputs, and each style has a colour and a shape. A wire takes the colour of the output port it leaves. You may name only the part you change: {"float": {"out": {"shape": "circle"}}} keeps the colour and every other port as it was.
shape is one of box (the default), circle or diamond. A dragged link also colours the input it hovers over with allowed or refused from colours, in that input’s shape.
Type |
Holds |
Default colour (in and out) |
Default shape |
|---|---|---|---|
|
whole numbers |
|
|
|
decimal numbers |
|
|
|
text |
|
|
|
true or false |
|
|
|
a picture |
|
|
|
a list of numbers |
|
|
metrics¶
Numbers, in canvas units: one unit is one pixel at zoom 1.
Key |
What it sets |
Default |
|---|---|---|
|
Width of a node card. |
|
|
Height of a card’s title bar. |
|
|
Height of one row of a card: an input or an output. |
|
|
Radius of a card’s corners. |
|
|
Thickness of the line round a card. |
|
|
Side of a port’s square marker. |
|
|
How far a port’s centre sits inside the card’s edge. |
|
|
How close a press must be to a port’s anchor to hit it. |
|
|
Thickness of a wire. |
|
|
Thickness of a selected wire. |
|
|
How solid a wire is where it crosses a card: 0 shows only the card, 1 shows only the wire. Off the cards a wire is always solid. |
|
|
Thickness of the outline round a selected node. |
|
|
The least a wire’s curve leaves sideways. |
|
|
The most a wire’s curve swings out when its ends are in one column. |
|
|
Height of a value box. |
|
|
Radius of a value box’s corners. |
|
|
Space between a port and its label. |
|
|
Space between the labels and the value boxes. |
|
|
Space between a card’s edge and its title. |
|
|
Space between text and the edge of its value box. |
|
|
How far below a row’s or the header’s centre a text baseline sits. |
|
|
Width of the three-bar icon. |
|
|
Thickness of one bar of the icon. |
|
|
Space between the bars of the icon. |
|
|
Distance between grid dots. |
|
|
Radius of a grid dot. |
|
page¶
Numbers, in CSS pixels, for the page’s own parts: the menus, the Run button, the input boxes and the error banner. Borders of 1 pixel and a few fixed paddings are not themed. The checkbox for a bool input is the browser’s own; accent tints it when ticked.
Key |
What it sets |
Default |
|---|---|---|
|
Size of text in the menus, the search box and the error banner. |
|
|
Size of the text on the Run button. |
|
|
Radius of a menu’s corners. |
|
|
Radius of the highlight on a menu entry. |
|
|
Space above and below the entries of a menu. |
|
|
Space left and right of a menu entry’s text. |
|
|
Space above and below a menu entry’s text. |
|
|
Narrowest a menu may be. |
|
|
How far a menu’s shadow spreads. |
|
|
How far a menu’s shadow sits below it. |
|
|
Radius of the Run button’s corners. |
|
|
Space left and right of the text on the Run button. |
|
|
Space above and below the text on the Run button. |
|
|
Distance of the Run button from the left edge of the window. |
|
|
Distance of the Run button from the top edge of the window. |
|
|
Space between the Run button’s triangle and its text. |
|
|
How far the Run button’s shadow spreads. |
|
|
How far the Run button’s shadow sits below it. |
|
|
Radius of the input boxes’ corners. |
|
|
Radius of the menu search box’s corners. |
|
|
Radius of the error banner’s corners. |
|
|
Distance of the error banner from the window’s edges. |
|
fonts¶
card, title and value are CSS font strings for the canvas: size, then family, with bold first if wanted. family and value_family are font families only. field_px is a number.
Key |
What it sets |
Default |
|---|---|---|
|
The canvas font for port names and values, as a CSS font string. |
|
|
The canvas font for the id and type name in a title bar. |
|
|
The canvas font for what sits in a value box: numbers, text, links. |
|
|
The family for the page’s own parts: menu, banner, buttons. |
|
|
The family for the text typed into an input box. |
|
|
The size of text in an input box at zoom 1, in pixels. |
|
Trying a Coolors palette¶
The menu button at the top right has two entries, Select theme and Load palette from Coolors link. For the second, paste a Coolors link
such as https://coolors.co/acadbc-9b9ece-6665dd-473bf0-000500 and press Enter:
the whole editor takes the palette’s colours at once. The link carries the
colours, so nothing is fetched, and Python is not told: reload the page to get
the theme Python holds back.
The colours are sorted by lightness, whatever order the link gives them. The darkest becomes the canvas, the next dark one the cards and menus, a mid tone the title bars and borders, the lightest the text, and the most saturated of the rest the accent (the Run button, the focus ring and the checkbox tick). Text, icon and outline colours are then moved lighter or darker until they meet WCAG 2.2 AA (4.5 to 1 for text, 3 to 1 for graphics), so every palette stays readable; the colours of a failed node and of the port types are kept as close to the theme’s as that allows. A link with fewer than 2 or more than 10 colours, or that is not a Coolors link, shows the reason in the banner. Shapes, sizes and fonts do not change.