simvx.core.ui.types

UI utility types — Colour, UIInputEvent, DragData, Theme, and theme descriptors.

Module Contents

Classes

Colour

Colour utility with named presets and hex parsing.

UIInputEvent

Input event for UI controls.

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__

[‘Colour’, ‘UIInputEvent’, ‘DragData’, ‘Theme’, ‘ThemeColour’, ‘ThemeSize’, ‘ThemeStyleBox’]

class simvx.core.ui.types.Colour[source]

Colour utility with named presets and hex parsing.

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

Example: panel.bg_colour = Colour.RED label.text_colour = Colour.hex(“#FF6600”) button.bg_colour = Colour.rgba(0.2, 0.4, 0.8)

WHITE

(1.0, 1.0, 1.0, 1.0)

BLACK

(0.0, 0.0, 0.0, 1.0)

RED

(1.0, 0.0, 0.0, 1.0)

GREEN

(0.0, 1.0, 0.0, 1.0)

BLUE

(0.0, 0.0, 1.0, 1.0)

YELLOW

(1.0, 1.0, 0.0, 1.0)

CYAN

(0.0, 1.0, 1.0, 1.0)

MAGENTA

(1.0, 0.0, 1.0, 1.0)

TRANSPARENT

(0.0, 0.0, 0.0, 0.0)

GRAY

(0.5, 0.5, 0.5, 1.0)

DARK_GRAY

(0.2, 0.2, 0.2, 1.0)

LIGHT_GRAY

(0.75, 0.75, 0.75, 1.0)

ORANGE

(1.0, 0.6, 0.0, 1.0)

PURPLE

(0.6, 0.2, 0.8, 1.0)

PINK

(1.0, 0.4, 0.7, 1.0)

static hex(h: str) tuple[float, float, float, float][source]

Parse hex colour string.

Supports ‘#RRGGBB’, ‘#RRGGBBAA’, ‘RRGGBB’, ‘RRGGBBAA’.

static rgba(r: float, g: float, b: float, a: float = 1.0) tuple[float, float, float, float][source]

Create colour from float components (0.0-1.0).

static from_255(r: int, g: int, b: int, a: int = 255) tuple[float, float, float, float][source]

Create colour from 0-255 integer components.

class simvx.core.ui.types.UIInputEvent(position=None, button: int = 0, pressed: bool = True, key: str = '', char: str = '')[source]

Input event for UI controls.

Attributes: position: Mouse position in screen coordinates. button: Mouse button (1=left, 2=middle, 3=right) or 0 for keyboard. pressed: True for press, False for release. key: Key name for keyboard events. char: Character typed (for text input).

Initialization

__slots__

(‘position’, ‘button’, ‘pressed’, ‘key’, ‘char’)

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]

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

Overrides are serializable — saved to scene files like Property values. Setting to None reverts to the theme default.

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__

(‘key’, ‘attr’, ‘name’)

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

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

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

Initialization

__slots__

(‘key’, ‘attr’, ‘name’, ‘default’)

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

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

Same semantics as :class:ThemeColour but for StyleBox values. Setting to None reverts to the theme default.

Initialization

__slots__

(‘key’, ‘attr’, ‘name’)

__set_name__(owner, name)[source]
__get__(obj, objtype=None)[source]
__set__(obj, value)[source]
__repr__()[source]
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

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.