Skip to content

Commit

Permalink
Merge pull request #71 from maxfordham/tidy-editgrid-internals-and-api
Browse files Browse the repository at this point in the history
Tidy editgrid internals and api
  • Loading branch information
jgunstone authored Nov 25, 2022
2 parents 610c678 + 058da8b commit fe9a64e
Show file tree
Hide file tree
Showing 58 changed files with 10,143 additions and 8,778 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ target/
/src/ipyautoui/autoui.ipynb
/src/ipyautoui/displayfile.ipynb
/src/ipyautoui/.ipynb_checkpoints
/src/ipyautoui/demo_schemas/.ipynb_checkpoints/
/src/ipyautoui/demo_schemas/.__pycache__/
/tests/.ipynb_checkpoints
/tests/__pycache__
/tests/testdata/.ipynb_checkpoints
Expand Down
232 changes: 116 additions & 116 deletions docs/autoui-simple.ipynb
Original file line number Diff line number Diff line change
@@ -1,117 +1,117 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "05fa98e6-8efc-4798-9124-1ff3be780512",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "43129c1d87b64d17a4458df03dd27636",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"AutoUi(children=(VBox(children=(HBox(children=(SaveButtonBar(children=(ToggleButton(value=False, button_style=…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import typing\n",
"from enum import Enum\n",
"from pydantic import Field, conint, constr\n",
"from ipyautoui.basemodel import BaseModel\n",
"from pydantic.color import Color\n",
"from datetime import datetime, date\n",
"import pathlib\n",
"\n",
"from ipyautoui import AutoUi\n",
"\n",
"STR_MARKDOWN = \"\"\"\n",
"See details here: [__commonmark__](https://commonmark.org/help/)\n",
"\n",
"or press the question mark button. \n",
"\"\"\"\n",
"\n",
"class GenderEnum(str, Enum):\n",
" \"\"\"available genders. this is just an example.\"\"\"\n",
"\n",
" male = \"male\"\n",
" female = \"female\"\n",
" other = \"other\"\n",
" not_given = \"not_given\"\n",
"\n",
"\n",
"class TestAutoLogicSimple(BaseModel):\n",
" \"\"\"this is a test UI form to demonstrate how pydantic class can be used to generate an ipywidget input form. \n",
" only simple datatypes used (i.e. not lists/arrays or objects)\n",
" \"\"\"\n",
"\n",
" string: str = Field(default=\"adsf\", description=\"a description about my string\")\n",
" int_slider: conint(ge=0, le=3) = 2\n",
" int_text: int = 1\n",
" int_range_slider: tuple[int, int] = Field(default=(0, 3), ge=0, le=4) # check\n",
" float_slider: float = Field(default=2.2, ge=0, le=3)\n",
" float_text: float = 2.2\n",
" float_text_locked: float = Field(default=2.2, disabled=True)\n",
" float_range_slider: tuple[float, float] = Field(default=(0, 2.2), ge=0, le=3.5)\n",
" checkbox: bool = True\n",
" dropdown: GenderEnum = Field(\n",
" default=GenderEnum.female, description=\"updated description\"\n",
" )\n",
" combobox: str = Field(\n",
" default=\"asd\", enum=[\"asd\", \"asdf\"], autoui=\"ipyautoui.autowidgets.Combobox\",\n",
" )\n",
" text: constr(min_length=0, max_length=20) = \"short text\"\n",
" text_area: constr(min_length=0, max_length=800) = Field(\n",
" \"long text \" * 50, description=\"long text field\"\n",
" )\n",
" markdown: str = Field(\n",
" STR_MARKDOWN, description=\"markdown widget!\", format=\"markdown\"\n",
" )\n",
" color_picker_ipywidgets: Color = \"#f5f595\"\n",
" date_picker: typing.Optional[\n",
" date\n",
" ] = date.today() # TODO: serialisation / parsing round trip not working...\n",
"\n",
"\n",
"AutoUi(TestAutoLogicSimple, path='ui.json') \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "174767f3-87e1-4717-8f74-2fd81b9bc138",
"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.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "05fa98e6-8efc-4798-9124-1ff3be780512",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "43129c1d87b64d17a4458df03dd27636",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"AutoUi(children=(VBox(children=(HBox(children=(SaveButtonBar(children=(ToggleButton(value=False, button_style=…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import typing as ty\n",
"from enum import Enum\n",
"from pydantic import Field, conint, constr\n",
"from ipyautoui.basemodel import BaseModel\n",
"from pydantic.color import Color\n",
"from datetime import datetime, date\n",
"import pathlib\n",
"\n",
"from ipyautoui import AutoUi\n",
"\n",
"STR_MARKDOWN = \"\"\"\n",
"See details here: [__commonmark__](https://commonmark.org/help/)\n",
"\n",
"or press the question mark button. \n",
"\"\"\"\n",
"\n",
"class GenderEnum(str, Enum):\n",
" \"\"\"available genders. this is just an example.\"\"\"\n",
"\n",
" male = \"male\"\n",
" female = \"female\"\n",
" other = \"other\"\n",
" not_given = \"not_given\"\n",
"\n",
"\n",
"class TestAutoLogicSimple(BaseModel):\n",
" \"\"\"this is a test UI form to demonstrate how pydantic class can be used to generate an ipywidget input form. \n",
" only simple datatypes used (i.e. not lists/arrays or objects)\n",
" \"\"\"\n",
"\n",
" string: str = Field(default=\"adsf\", description=\"a description about my string\")\n",
" int_slider: conint(ge=0, le=3) = 2\n",
" int_text: int = 1\n",
" int_range_slider: tuple[int, int] = Field(default=(0, 3), ge=0, le=4) # check\n",
" float_slider: float = Field(default=2.2, ge=0, le=3)\n",
" float_text: float = 2.2\n",
" float_text_locked: float = Field(default=2.2, disabled=True)\n",
" float_range_slider: tuple[float, float] = Field(default=(0, 2.2), ge=0, le=3.5)\n",
" checkbox: bool = True\n",
" dropdown: GenderEnum = Field(\n",
" default=GenderEnum.female, description=\"updated description\"\n",
" )\n",
" combobox: str = Field(\n",
" default=\"asd\", enum=[\"asd\", \"asdf\"], autoui=\"ipyautoui.autowidgets.Combobox\",\n",
" )\n",
" text: constr(min_length=0, max_length=20) = \"short text\"\n",
" text_area: constr(min_length=0, max_length=800) = Field(\n",
" \"long text \" * 50, description=\"long text field\"\n",
" )\n",
" markdown: str = Field(\n",
" STR_MARKDOWN, description=\"markdown widget!\", format=\"markdown\"\n",
" )\n",
" color_picker_ipywidgets: Color = \"#f5f595\"\n",
" date_picker: ty.Optional[\n",
" date\n",
" ] = date.today() # TODO: serialisation / parsing round trip not working...\n",
"\n",
"\n",
"AutoUi(TestAutoLogicSimple, path='ui.json') \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "174767f3-87e1-4717-8f74-2fd81b9bc138",
"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.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit fe9a64e

Please sign in to comment.