MCPcopy
hub / github.com/StructuredLabs/preswald / checkbox

Function checkbox

preswald/interfaces/components.py:173–191  ·  view source on GitHub ↗

Create a checkbox component with consistent ID based on label.

(label: str, default: bool = False, size: float = 1.0, component_id: str | None = None, **kwargs)

Source from the content-addressed store, hash-verified

171
172@with_render_tracking("checkbox")
173def checkbox(label: str, default: bool = False, size: float = 1.0, component_id: str | None = None, **kwargs) -> ComponentReturn:
174 """Create a checkbox component with consistent ID based on label."""
175 service = PreswaldService.get_instance()
176
177 # Get current state or use default
178 current_value = service.get_component_state(component_id)
179 if current_value is None:
180 current_value = default
181
182 logger.debug(f"Creating checkbox component with id {component_id}, label: {label}")
183 component = {
184 "type": "checkbox",
185 "id": component_id,
186 "label": label,
187 "value": current_value,
188 "size": size,
189 }
190
191 return ComponentReturn(current_value, component)
192
193
194# def fastplotlib(fig: "fplt.Figure", size: float = 1.0) -> str:

Callers 1

checkbox_demoFunction · 0.90

Calls 3

ComponentReturnClass · 0.90
get_component_stateMethod · 0.80
get_instanceMethod · 0.45

Tested by

no test coverage detected