libstp.ui.widgets ================= .. py:module:: libstp.ui.widgets .. autoapi-nested-parse:: UI Widgets - Type-safe widget definitions for dynamic screens. These dataclasses serialize to JSON and are rendered by Flutter. Classes ------- .. autoapisummary:: libstp.ui.widgets.Widget libstp.ui.widgets.Text libstp.ui.widgets.Icon libstp.ui.widgets.Spacer libstp.ui.widgets.Divider libstp.ui.widgets.StatusBadge libstp.ui.widgets.StatusIcon libstp.ui.widgets.HintBox libstp.ui.widgets.DistanceBadge libstp.ui.widgets.ResultsTable libstp.ui.widgets.Button libstp.ui.widgets.Slider libstp.ui.widgets.Checkbox libstp.ui.widgets.Dropdown libstp.ui.widgets.NumericKeypad libstp.ui.widgets.NumericInput libstp.ui.widgets.TextInput libstp.ui.widgets.SensorValue libstp.ui.widgets.SensorGraph libstp.ui.widgets.LightBulb libstp.ui.widgets.AnimatedRobot libstp.ui.widgets.CircularSlider libstp.ui.widgets.ProgressSpinner libstp.ui.widgets.PulsingArrow libstp.ui.widgets.RobotDrivingAnimation libstp.ui.widgets.MeasuringTape libstp.ui.widgets.CalibrationChart libstp.ui.widgets.Row libstp.ui.widgets.Column libstp.ui.widgets.Center libstp.ui.widgets.Card libstp.ui.widgets.Split libstp.ui.widgets.Expanded Module Contents --------------- .. py:class:: Widget Bases: :py:obj:`abc.ABC` Base class for all widgets. .. py:method:: to_dict() -> dict Convert to JSON-serializable dict. .. py:class:: Text Bases: :py:obj:`Widget` Text display widget. .. py:attribute:: text :type: str .. py:attribute:: size :type: str :value: 'medium' .. py:attribute:: color :type: Optional[str] :value: None .. py:attribute:: bold :type: bool :value: False .. py:attribute:: muted :type: bool :value: False .. py:attribute:: align :type: str :value: 'left' .. py:class:: Icon Bases: :py:obj:`Widget` Material icon widget. .. py:attribute:: name :type: str .. py:attribute:: size :type: int :value: 24 .. py:attribute:: color :type: Optional[str] :value: None .. py:class:: Spacer Bases: :py:obj:`Widget` Vertical spacing widget. .. py:attribute:: height :type: int :value: 16 .. py:class:: Divider Bases: :py:obj:`Widget` Horizontal divider line. .. py:attribute:: thickness :type: int :value: 1 .. py:attribute:: color :type: Optional[str] :value: None .. py:class:: StatusBadge Bases: :py:obj:`Widget` Colored pill/badge with text (e.g., "LIGHT ON"). .. py:attribute:: text :type: str .. py:attribute:: color :type: str :value: 'grey' .. py:attribute:: glow :type: bool :value: False .. py:class:: StatusIcon Bases: :py:obj:`Widget` Animated circle with icon inside. .. py:attribute:: icon :type: str .. py:attribute:: color :type: str :value: 'green' .. py:attribute:: animated :type: bool :value: True .. py:class:: HintBox Bases: :py:obj:`Widget` Highlighted hint box (e.g., "Press button when ready"). .. py:attribute:: text :type: str .. py:attribute:: icon :type: str :value: 'touch_app' .. py:attribute:: style :type: str :value: 'normal' .. py:class:: DistanceBadge Bases: :py:obj:`Widget` Distance value display badge. .. py:attribute:: value :type: float .. py:attribute:: unit :type: str :value: 'cm' .. py:attribute:: color :type: str :value: 'blue' .. py:class:: ResultsTable Bases: :py:obj:`Widget` Key-value results table. .. py:attribute:: rows :type: List[tuple] :value: [] .. py:class:: Button Bases: :py:obj:`Widget` Clickable button. .. py:attribute:: id :type: str .. py:attribute:: label :type: str .. py:attribute:: style :type: str :value: 'primary' .. py:attribute:: icon :type: Optional[str] :value: None .. py:attribute:: disabled :type: bool :value: False .. py:class:: Slider Bases: :py:obj:`Widget` Slider input for numeric values. .. py:attribute:: id :type: str .. py:attribute:: min :type: float .. py:attribute:: max :type: float .. py:attribute:: value :type: float :value: 0 .. py:attribute:: label :type: Optional[str] :value: None .. py:attribute:: show_value :type: bool :value: True .. py:class:: Checkbox Bases: :py:obj:`Widget` Checkbox toggle. .. py:attribute:: id :type: str .. py:attribute:: label :type: str .. py:attribute:: value :type: bool :value: False .. py:class:: Dropdown Bases: :py:obj:`Widget` Dropdown selection. .. py:attribute:: id :type: str .. py:attribute:: options :type: List[str] :value: [] .. py:attribute:: value :type: Optional[str] :value: None .. py:attribute:: label :type: Optional[str] :value: None .. py:class:: NumericKeypad Bases: :py:obj:`Widget` Touch-friendly numeric keypad (0-9, ., backspace). .. py:class:: NumericInput Bases: :py:obj:`Widget` Large numeric display with optional +/- buttons. .. py:attribute:: id :type: str .. py:attribute:: value :type: float :value: 0 .. py:attribute:: unit :type: str :value: '' .. py:attribute:: min_value :type: Optional[float] :value: None .. py:attribute:: max_value :type: Optional[float] :value: None .. py:attribute:: show_adjust_buttons :type: bool :value: True .. py:class:: TextInput Bases: :py:obj:`Widget` Text input field. .. py:attribute:: id :type: str .. py:attribute:: value :type: str :value: '' .. py:attribute:: label :type: Optional[str] :value: None .. py:attribute:: placeholder :type: str :value: '' .. py:class:: SensorValue Bases: :py:obj:`Widget` Large sensor value display. .. py:attribute:: port :type: int .. py:attribute:: sensor_type :type: str :value: 'analog' .. py:class:: SensorGraph Bases: :py:obj:`Widget` Real-time sensor line graph. .. py:attribute:: port :type: int .. py:attribute:: sensor_type :type: str :value: 'analog' .. py:attribute:: max_points :type: int :value: 50 .. py:class:: LightBulb Bases: :py:obj:`Widget` Animated light bulb visualization. .. py:attribute:: is_on :type: bool :value: False .. py:class:: AnimatedRobot Bases: :py:obj:`Widget` Robot with spinning wheels visualization. .. py:attribute:: moving :type: bool :value: False .. py:attribute:: size :type: int :value: 120 .. py:class:: CircularSlider Bases: :py:obj:`Widget` Circular slider for motor/servo control. .. py:attribute:: id :type: str .. py:attribute:: min :type: float .. py:attribute:: max :type: float .. py:attribute:: value :type: float :value: 0 .. py:attribute:: label :type: Optional[str] :value: None .. py:class:: ProgressSpinner Bases: :py:obj:`Widget` Circular loading spinner. .. py:attribute:: size :type: int :value: 24 .. py:attribute:: color :type: Optional[str] :value: None .. py:class:: PulsingArrow Bases: :py:obj:`Widget` Animated pulsing arrow. .. py:attribute:: direction :type: str :value: 'right' .. py:class:: RobotDrivingAnimation Bases: :py:obj:`Widget` Robot driving on track animation. .. py:attribute:: target_distance :type: float :value: 30.0 .. py:class:: MeasuringTape Bases: :py:obj:`Widget` Animated measuring tape. .. py:attribute:: distance :type: float :value: 30.0 .. py:class:: CalibrationChart Bases: :py:obj:`Widget` Static scatter/line chart for calibration data. Shows collected sample points with horizontal threshold lines. .. py:attribute:: samples :type: List[float] :value: [] .. py:attribute:: thresholds :type: List[tuple] :value: [] .. py:attribute:: height :type: int :value: 200 .. py:class:: Row Bases: :py:obj:`Widget` Horizontal layout - children side by side. .. py:attribute:: children :type: List[Widget] :value: [] .. py:attribute:: align :type: str :value: 'center' .. py:attribute:: spacing :type: int :value: 8 .. py:class:: Column Bases: :py:obj:`Widget` Vertical layout - children stacked. .. py:attribute:: children :type: List[Widget] :value: [] .. py:attribute:: align :type: str :value: 'stretch' .. py:attribute:: spacing :type: int :value: 12 .. py:class:: Center Bases: :py:obj:`Widget` Center children vertically and horizontally. .. py:attribute:: children :type: List[Widget] :value: [] .. py:class:: Card Bases: :py:obj:`Widget` Card container with optional title. .. py:attribute:: children :type: List[Widget] :value: [] .. py:attribute:: title :type: Optional[str] :value: None .. py:attribute:: padding :type: int :value: 16 .. py:class:: Split Bases: :py:obj:`Widget` Left-right split layout. .. py:attribute:: left :type: List[Widget] :value: [] .. py:attribute:: right :type: List[Widget] :value: [] .. py:attribute:: ratio :type: tuple :value: (1, 1) .. py:class:: Expanded Bases: :py:obj:`Widget` Expand child to fill available space. .. py:attribute:: child :type: Widget :value: None .. py:attribute:: flex :type: int :value: 1