simvx.core.ui.types

UI utility types: DragData, Theme, and theme descriptors.

The :class:Colour palette/Property lives in :mod:simvx.core.properties.

Module Contents

Classes

DragData

Data being dragged between controls.

ThemeColour

Descriptor that reads a colour from the theme unless explicitly overridden.

ThemeSize

Descriptor that reads a layout size from the theme unless overridden.

ThemeStyleBox

Descriptor that reads a StyleBox from the theme unless explicitly overridden.

Theme

UI theme controlling colours, fonts, and sizing.

Data

API

simvx.core.ui.types.__all__

[‘DragData’, ‘GuiInputEvent’, ‘Theme’, ‘ThemeColour’, ‘ThemeSize’, ‘ThemeStyleBox’]

class simvx.core.ui.types.DragData(data: Any = None, preview: Any = None)[source]

Data being dragged between controls.

Attributes: data: Arbitrary payload. preview: Optional visual preview control shown during drag. source: Control the drag originated from (set by the system).

Initialization

__slots__

(‘data’, ‘preview’, ‘source’)

class simvx.core.ui.types.ThemeColour(key: str)[source]

Bases: simvx.core.ui.types._ThemeAttr

Descriptor that reads a colour from the theme unless explicitly overridden.

Usage::

class Button(Control):
    bg_colour = ThemeColour("btn_bg")
    text_colour = ThemeColour("text")

btn.bg_colour = Colour.RED   # override
btn.bg_colour = None        # revert to theme

Initialization

__slots__

()

__set_name__(owner, name)
__get__(obj, objtype=None)
__set__(obj, value)
__repr__()
class simvx.core.ui.types.ThemeSize(key: str, default: float = 0.0)[source]

Bases: simvx.core.ui.types._ThemeAttr

Descriptor that reads a layout size from the theme unless overridden.

Same semantics as :class:ThemeColour but for numeric layout values.

Initialization

__slots__

(‘default’,)

__set_name__(owner, name)
__get__(obj, objtype=None)
__set__(obj, value)
__repr__()
class simvx.core.ui.types.ThemeStyleBox(key: str)[source]

Bases: simvx.core.ui.types._ThemeAttr

Descriptor that reads a StyleBox from the theme unless explicitly overridden.

Same semantics as :class:ThemeColour but for StyleBox values.

Initialization

__slots__

()

__set_name__(owner, name)
__get__(obj, objtype=None)
__set__(obj, value)
__repr__()
class simvx.core.ui.types.Theme[source]

UI theme controlling colours, fonts, and sizing.

All colours are float tuples (r, g, b, a) in 0.0-1.0 range.

Example: theme = Theme() theme.colours[‘accent’] = Colour.hex(“#33CCFF”) theme.sizes[‘button_height’] = 40

Initialization

property min_hit_size: float[source]

The smallest square a finger’s press counts as landing on a touch target, in engine units.

A control whose :attr:~.core.Control.touch_target is set is hit by a finger anywhere in its rect grown, centred, to at least this on each axis; its layout and what it draws are untouched. Only a finger gets the growth, so a mouse, a pen and every desktop see the control’s own rect. 44 by default, the number Apple, Material and WCAG land on, and an engine unit is one density-independent pixel, so it is the same size across the glass on every screen.

Assign a number to change it for the whole theme, 0 to switch it off, or None for the default again.

get_colour(key: str, default=(1, 1, 1, 1)) → tuple[float, float, float, float][source]

Get colour by key with fallback.

get_size(key: str, default: float = 0) → float[source]

Get size by key with fallback.