{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "1ed0f615-ee6d-4bc1-bd8e-f95ca4e61854", "metadata": {}, "outputs": [], "source": [ "%run ../src/ipyautoui/__init__.py\n", "%load_ext lab_black" ] }, { "cell_type": "code", "execution_count": 4, "id": "f748910d-f0ff-4541-9578-c879a26f98de", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'IntText': WidgetMapper(fn_filt=, widget=),\n", " 'SelectMultiple': WidgetMapper(fn_filt=, widget=),\n", " 'array': WidgetMapper(fn_filt=, widget=),\n", " 'Text': WidgetMapper(fn_filt=, widget=),\n", " 'FloatRangeSlider': WidgetMapper(fn_filt=, widget=),\n", " 'Markdown': WidgetMapper(fn_filt=, widget=),\n", " 'FloatText': WidgetMapper(fn_filt=, widget=),\n", " 'IntRangeSlider': WidgetMapper(fn_filt=, widget=),\n", " 'FloatSlider': WidgetMapper(fn_filt=, widget=),\n", " 'Checkbox': WidgetMapper(fn_filt=, widget=),\n", " 'object': WidgetMapper(fn_filt=, widget=),\n", " 'Textarea': WidgetMapper(fn_filt=, widget=),\n", " 'Date': WidgetMapper(fn_filt=, widget=),\n", " 'Color': WidgetMapper(fn_filt=, widget=),\n", " 'IntSlider': WidgetMapper(fn_filt=, widget=),\n", " 'Dropdown': WidgetMapper(fn_filt=, widget=),\n", " 'AutoOveride': WidgetMapper(fn_filt=, widget=),\n", " 'DataFrame': WidgetMapper(fn_filt=, widget=)}" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from ipyautoui.automapschema import (\n", " map_widget,\n", " WidgetCaller,\n", " update_widgets_map,\n", " attach_schema_refs,\n", " frozenmap,\n", " obj_from_importstr,\n", ")\n", "from ipyautoui.autoipywidget import AutoObject\n", "from ipyautoui.automapschema import map_widget, get_widgets_map\n", "\n", "dict(get_widgets_map())" ] }, { "cell_type": "code", "execution_count": 11, "id": "728001d7-856a-492a-907f-fba9ca3da656", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "095b22a32c85488abd0b023dcdf0ca7f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "AutoUi(children=(VBox(children=(HBox(), HBox(children=(ToggleButton(value=False, icon='code', layout=Layout(di…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from pydantic import BaseModel\n", "\n", "\n", "class Test(BaseModel):\n", " __root__: str = \"asdf\"\n", "\n", "\n", "# class Test(BaseModel):\n", "# string: str = \"asdf\"\n", "\n", "\n", "aui = AutoUi(Test)\n", "display(aui)" ] }, { "cell_type": "code", "execution_count": 9, "id": "f86a1721-f29b-4fa1-9164-a0c1d1f5928c", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "d0252c6ab73a4992b313c5c4cc459d55", "version_major": 2, "version_minor": 0 }, "text/plain": [ "AutoObject(children=(HBox(children=(Text(value='adsf'), HTML(value='String, a description about my s…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "if __name__ == \"__main__\":\n", " from ipyautoui.test_schema import TestAutoLogic, TestAutoLogicSimple\n", "\n", " schema = TestAutoLogicSimple.schema().copy()\n", " aui = AutoObject(\n", " TestAutoLogicSimple,\n", " # path=\"test.json\",\n", " # show_raw=False,\n", " # fn_save=lambda: print(\"test onsave\"),\n", " )\n", " display(aui)" ] }, { "cell_type": "code", "execution_count": 12, "id": "ee2b40c0-5bf4-4ad8-be8e-67248e79a24a", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "9ece6abc7d4a4aabba2902486b00735c", "version_major": 2, "version_minor": 0 }, "text/plain": [ "AutoIpywidget(children=(AutoObject(children=(HBox(children=(Text(value='adsf'), HTML(value='String, …" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "if __name__ == \"__main__\":\n", " from ipyautoui.test_schema import TestAutoLogic, TestAutoLogicSimple\n", "\n", " schema = TestAutoLogicSimple.schema().copy()\n", " aui = AutoObject(\n", " TestAutoLogic,\n", " # path=\"test.json\",\n", " # show_raw=False,\n", " # fn_save=lambda: print(\"test onsave\"),\n", " )\n", " display(aui)" ] }, { "cell_type": "code", "execution_count": null, "id": "f7f6f848-8441-483c-b87c-59f9889e9cde", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 13, "id": "c0922f0f-3843-4271-b523-6dea0029ed85", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "8d9d5be47e3142ddbbc4f0c4f7c0953b", "version_major": 2, "version_minor": 0 }, "text/plain": [ "AutoIpywidget(children=(AutoArray(children=(HBox(layout=Layout(display='flex', flex='flex-grow')), VBox(childr…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from ipyautoui.custom.iterable import AutoArray\n", "\n", "\n", "class Test(BaseModel):\n", " __root__: str = \"asdf\"\n", "\n", "\n", "class TestArray(BaseModel):\n", " __root__: list[Test] = [Test()]\n", "\n", "\n", "AutoObject(schema=TestArray.schema())" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.12" } }, "nbformat": 4, "nbformat_minor": 5 }