simvx.core.ui.theme¶
Shared application theme – single source of truth for colours and layout.
AppTheme extends the base Theme with named attributes covering
backgrounds, text, accents, semantic colours, buttons, editor viewports,
gizmos, IDE minimap, autocomplete, and scrollbar styling.
SyntaxTheme provides syntax highlighting colours for code editors.
Factory classmethods dark(), light(), and monokai() return
pre-configured instances. Module-level get_theme() / set_theme()
manage a runtime-swappable singleton.
Usage::
from simvx.core.ui.theme import AppTheme, get_theme, set_theme
theme = get_theme() # module-level singleton (dark by default)
bg = theme.bg # direct attribute access
set_theme(AppTheme.monokai()) # runtime theme switch
Module Contents¶
Classes¶
Themed background with optional gradient and per-side embossed borders. |
|
Syntax highlighting colour set for code editors. |
|
Full application theme with named colour and layout attributes. |
Functions¶
Return the current application theme singleton. |
|
Return the current theme generation counter. |
|
Swap the module-level theme singleton and bump the generation counter. |
|
Return multiple of the theme font size in logical pixels. |
Data¶
API¶
- simvx.core.ui.theme.Colour4¶
None
- class simvx.core.ui.theme.StyleBox(bg_colour: simvx.core.ui.theme.Colour4 = (0.2, 0.2, 0.2, 1.0), bg_gradient: tuple[simvx.core.ui.theme.Colour4, simvx.core.ui.theme.Colour4] | None = None, border_colour: simvx.core.ui.theme.Colour4 = (0.3, 0.3, 0.3, 1.0), border_top: simvx.core.ui.theme.Colour4 | None = None, border_bottom: simvx.core.ui.theme.Colour4 | None = None, border_left: simvx.core.ui.theme.Colour4 | None = None, border_right: simvx.core.ui.theme.Colour4 | None = None, border_width: float = 1.0, content_margin: float = 2.0)[source]¶
Themed background with optional gradient and per-side embossed borders.
Use
draw()to render the background and borders. Useinsetto offset child content past the border + content margin.Initialization
- __slots__¶
(‘bg_colour’, ‘bg_gradient’, ‘border_colour’, ‘border_top’, ‘border_bottom’, ‘border_left’, ‘border_…
- property inset: float¶
Total inward offset (border + content margin) for child positioning.
- class simvx.core.ui.theme.SyntaxTheme(keyword: simvx.core.ui.theme.Colour4 = (0.4, 0.6, 1.0, 1.0), string: simvx.core.ui.theme.Colour4 = (0.5, 0.9, 0.5, 1.0), comment: simvx.core.ui.theme.Colour4 = (0.5, 0.5, 0.5, 1.0), number: simvx.core.ui.theme.Colour4 = (1.0, 0.7, 0.3, 1.0), decorator: simvx.core.ui.theme.Colour4 = (1.0, 0.9, 0.4, 1.0), builtin: simvx.core.ui.theme.Colour4 = (0.4, 0.9, 0.9, 1.0), normal: simvx.core.ui.theme.Colour4 = (0.9, 0.9, 0.9, 1.0))[source]¶
Syntax highlighting colour set for code editors.
Each attribute is a Colour4 tuple used to colour a token category.
Initialization
- __slots__¶
(‘keyword’, ‘string’, ‘comment’, ‘number’, ‘decorator’, ‘builtin’, ‘normal’)
- class simvx.core.ui.theme.AppTheme[source]¶
Bases:
simvx.core.ui.types.ThemeFull application theme with named colour and layout attributes.
Subclasses :class:
ThemesoControl.get_theme()still works. All attributes are also written intoself.colours/self.sizesso the dict-basedget_colour()/get_size()API stays valid.Initialization
- classmethod dark() simvx.core.ui.theme.AppTheme[source]¶
Dark theme (default).
- classmethod abyss() simvx.core.ui.theme.AppTheme[source]¶
Abyss — near-black with a subtle cool-blue tint. OLED-friendly.
- classmethod midnight() simvx.core.ui.theme.AppTheme[source]¶
Midnight — near-black with a subtle warm-green tint. OLED-friendly.
- classmethod light() simvx.core.ui.theme.AppTheme[source]¶
Light theme with bright backgrounds.
- classmethod monokai() simvx.core.ui.theme.AppTheme[source]¶
Monokai-inspired theme.
- classmethod solarised_dark() simvx.core.ui.theme.AppTheme[source]¶
Solarised Dark theme — Ethan Schoonover’s warm-tinted dark palette.
- classmethod nord() simvx.core.ui.theme.AppTheme[source]¶
Nord theme — Arctic, north-bluish palette by Arctic Ice Studio.
- get_colour(key: str, default=(1, 1, 1, 1)) tuple[float, float, float, float]¶
- get_size(key: str, default: float = 0) float¶
- simvx.core.ui.theme.get_theme() simvx.core.ui.theme.AppTheme[source]¶
Return the current application theme singleton.
- simvx.core.ui.theme.theme_generation() int[source]¶
Return the current theme generation counter.
Incremented by
set_theme(). Draw caches use this to detect global theme changes without walking the widget tree.
- simvx.core.ui.theme.set_theme(theme: simvx.core.ui.theme.AppTheme) None[source]¶
Swap the module-level theme singleton and bump the generation counter.
All
ThemeColour/ThemeStyleBoxdescriptors resolve on access, so widgets pick up the new theme on their next draw. The generation counter invalidates draw caches so that next draw actually happens.
- simvx.core.ui.theme.em(multiple: float) float[source]¶
Return multiple of the theme font size in logical pixels.
Use for layout dimensions that should scale with the user’s font-size preference. Does NOT multiply by
ui_scale— UI layout works in logical (window) coordinates; the GPU rendering pipeline handles the logical-to-physical conversion separately via Draw2DPass::row_height = em(2.18) # ~24 px at default 11pt padding = em(0.55) # ~6 px label_w = em(7.27) # ~80 px