{ "cells": [ { "cell_type": "markdown", "id": "0", "metadata": {}, "source": [ "
You are looking at an HTML rendering of the generated widgets, they are lacking responsiveness due to no Python kernel being available for callbacks.
" ] }, { "cell_type": "markdown", "id": "1", "metadata": {}, "source": [ "# Form from JSONSchema" ] }, { "cell_type": "markdown", "id": "2", "metadata": {}, "source": [ "Use a raw JSON Schema document to generate a form with validated defaults." ] }, { "cell_type": "code", "execution_count": null, "id": "3", "metadata": {}, "outputs": [], "source": [ "from ipywidgets_jsonschema import Form\n", "\n", "schema = {\n", " \"type\": \"object\",\n", " \"properties\": {\n", " \"experiment_id\": {\n", " \"type\": \"string\",\n", " \"pattern\": \"^EXP-[0-9]{4}$\",\n", " \"default\": \"EXP-0001\",\n", " },\n", " \"replicates\": {\"type\": \"integer\", \"minimum\": 1, \"maximum\": 10, \"default\": 3},\n", " \"mode\": {\"type\": \"string\", \"enum\": [\"fast\", \"accurate\"], \"default\": \"fast\"},\n", " \"temperature_c\": {\n", " \"type\": \"number\",\n", " \"minimum\": -20,\n", " \"maximum\": 120,\n", " \"default\": 22.5,\n", " },\n", " \"send_report\": {\"type\": \"boolean\", \"default\": False},\n", " },\n", " \"required\": [\"experiment_id\", \"replicates\", \"mode\", \"temperature_c\", \"send_report\"],\n", "}\n", "\n", "json_schema_form = Form(schema, use_sliders=True, show_descriptions=True)\n", "json_schema_form.show()" ] }, { "cell_type": "code", "execution_count": null, "id": "4", "metadata": {}, "outputs": [], "source": [ "json_schema_form.data" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3" } }, "nbformat": 4, "nbformat_minor": 5 }