simvx.core.ui.types

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

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

Module Contents

Classes

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__

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

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.