{ "cells": [ { "cell_type": "markdown", "id": "5119f197-19da-488e-a15f-5c478f55cbef", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "# AutoDisplay" ] }, { "cell_type": "markdown", "id": "03047eb4-67ea-4453-b08b-44296528c8f4", "metadata": {}, "source": [ "## Render a list of files" ] }, { "cell_type": "code", "execution_count": 1, "id": "cd1a6c89-b5c1-4234-99e8-ad4a93036de8", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [ "remove-cell" ] }, "outputs": [], "source": [ "%run __init__.py\n", "%load_ext lab_black" ] }, { "cell_type": "markdown", "id": "9f7f6255-f439-42f6-8a61-774594a79ea3", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "```{warning} the demo requires a python kernel to run. Try on Binder [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/maxfordham/ipyautoui/HEAD?urlpath=voila%2Frender%2Fdocs%2Fdemo.ipynb)\n", "```" ] }, { "cell_type": "code", "execution_count": 10, "id": "d1307a87-a12c-4f53-8c31-e383eca373e3", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "36d846a817534b9a868ab45f64390a75", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(VBox(children=(HBox(), HBox())), VBox(children=(DisplayObject(children=(HBox(children=(Valid(va…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from ipyautoui.demo_schemas import CoreIpywidgets\n", "from ipyautoui import AutoUi, AutoDisplay\n", "from ipyautoui.autodisplay import DisplayPath\n", "from ipyautoui.constants import load_test_constants\n", "from IPython.display import display\n", "import pathlib\n", "\n", "tests_constants = load_test_constants()\n", "paths = list(load_test_constants().DIR_FILETYPES.glob(\"*.*\"))\n", "ad = AutoDisplay.from_paths(paths, display_showhide=False)\n", "display(ad)" ] }, { "cell_type": "markdown", "id": "20380660-7a99-42d1-b31a-25f0e0a87401", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "## Create a custom renderer" ] }, { "cell_type": "code", "execution_count": 7, "id": "7b833bf5-5c24-4e38-8d2e-393558dde75e", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6a167136f21a479da9a1e0a984c18dde", "version_major": 2, "version_minor": 0 }, "text/plain": [ "VBox(children=(VBox(children=(HBox(), HBox())), VBox(children=(DisplayObject(children=(HBox(children=(Valid(va…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from ipyautoui.demo_schemas import CoreIpywidgets\n", "\n", "user_file_renderers = AutoUi.create_autodisplay_map(\n", " ext=\".aui.json\", schema=CoreIpywidgets\n", ")\n", "tests_constants.PATH_TEST_AUI.write_text(\n", " CoreIpywidgets(int_text_req=3, int_text_nullable=None).model_dump_json(indent=4)\n", ")\n", "\n", "test_ui = AutoDisplay.from_paths(\n", " paths=[tests_constants.PATH_TEST_AUI],\n", " renderers=user_file_renderers,\n", " display_showhide=False,\n", ")\n", "\n", "display(test_ui)" ] }, { "cell_type": "code", "execution_count": null, "id": "9d7e3a4e-b7f9-4ff6-a9de-bb10e49851a0", "metadata": {}, "outputs": [], "source": [] } ], "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.11.5" }, "vscode": { "interpreter": { "hash": "8ada13db5691318db95c45469f21e1a7752ab0a7ab2e35f607cb2aeb67fe81be" } } }, "nbformat": 4, "nbformat_minor": 5 }