You are looking at an HTML rendering of the generated widgets, they are lacking responsiveness due to no Python kernel being available for callbacks.
Form from Pydantic modelsΒΆ
Pass a Pydantic model class directly. The schema is derived automatically.
[1]:
from pydantic import BaseModel, Field
from ipywidgets_jsonschema import Form
class InstrumentConfig(BaseModel):
instrument_name: str = Field("spectrometer", description="Display name")
serial_number: str = Field("ABC-0001", pattern=r"^[A-Z]{3}-[0-9]{4}$")
sample_rate_hz: int = Field(1000, ge=1, le=5000)
calibration_gain: float = Field(1.0, ge=0.1, le=10.0)
enabled: bool = True
pydantic_form = Form(InstrumentConfig, show_descriptions=True)
pydantic_form.show()
[2]:
pydantic_form.data
[2]:
{'instrument_name': 'spectrometer',
'serial_number': 'ABC-0001',
'sample_rate_hz': 1000,
'calibration_gain': 1.0,
'enabled': True}