from IPython.display import IFrame
IFrame(="600",
width="500",
height="allow-same-origin allow-scripts allow-popups",
sandbox="0",
frameborder="https://videos.koumoul.com/videos/embed/29d12ba2-f694-4659-8027-e9386692d8b5",
src )
AutoVuetify
AutoVjsf
works in exactly the same way as AutoUi
, but instead of using ipywidgets
to render the JSON schema it uses ipyvuetify and vuetify-jsonschema-form.
vuetify-jsonschema-form documentation is awesome!
See there docs and the Video below to see what you can do. Once you’ve created a schema based on those docs it should work with AutoVjsf
vjsf uses “-” in the schema keys for specifying formatting (e.g. “x-display”)… when you’re using pydantic to make the schema, “-” cannot be used field names, use __“_“__ instead (e.g. ”x_display”) and AutoVjsf does the conversion.
Creating Simple Widget
So let’s create a simple pydantic class. Here we have one text field.
from ipyautoui import AutoVjsf
import json
from pydantic import BaseModel, Field
from ipyautoui.constants import DIR_MODULE
from ipyautoui._utils import display_pydantic_json
# create a pydantic model (or a json-schema) defining the fields of interest
class AutoUiExample(BaseModel):
str = Field(default="Test", description="This description is very important")
text:
import pathlib
= {"text": "this is a value"}
value = AutoVjsf(schema=AutoUiExample, value=value, path=pathlib.Path("test.json"))
ui # uncomment display(ui)
both a value and a path given. value will be used.
A more Complex Example Model
Let’s look at a complete pydantic model producing all of the possible widgets. within import ipyautoui.demo_schemas
there is a class called CoreIpywidgets
that outlines what is possible. Explore the python file below.
from ipyautoui.demo_schemas import CoreIpywidgets
= AutoVjsf(CoreIpywidgets)
ui = True
ui.show_raw ui