Name | ipyformkit JSON |
Version |
0.2.2
JSON |
| download |
home_page | None |
Summary | Easy form creation with ipywidgets in Jupyter |
upload_time | 2025-07-09 08:31:25 |
maintainer | None |
docs_url | None |
author | Richard Hoppe |
requires_python | >=3.7 |
license | MIT License
Copyright (c) 2025 RMHoppe
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
|
keywords |
widgets
ipywidgets
form
jupyter
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# IpyFormKit
IpyFormKit is a Python library for creating dynamic, interactive forms using `ipywidgets` in Jupyter notebooks. It simplifies the process of building forms for data entry, configuration, or experimentation with minimal code.
## Features
- **Dynamic Forms**: Automatically generate forms from dictionaries with support for various input types (text, numbers, dropdowns, checkboxes, etc.).
- **Custom Widgets**: Includes specialized widgets like `FileAutocomplete` for file selection and `CollapsibleVBox` for collapsible sections.
- **Validation and Logic**: Add conditions to disable, hide, or validate fields dynamically based on user input.
- **Masonry Layout**: Organize multiple forms in a responsive masonry-style layout.
- **Adaptive CSS Styling** Seamless integration with Jupyter Notebook/Lab, Google Colab and VScode themes.
<div style="display: flex; justify-content: space-around;">
<img src="https://raw.githubusercontent.com/RMHoppe/IpyFormKit/refs/heads/main/images/jupyterlab-light.png" alt="Jupyter Lab Light Example" width="300">
<img src="https://raw.githubusercontent.com/RMHoppe/IpyFormKit/refs/heads/main/images/jupyterlab-dark.png" alt="Jupyter Lab Dark Example" width="300">
<img src="https://raw.githubusercontent.com/RMHoppe/IpyFormKit/refs/heads/main/images/vscode.png" alt="VSCode Example" width="300">
<img src="https://raw.githubusercontent.com/RMHoppe/IpyFormKit/refs/heads/main/images/googlecolab.png" alt="Google Colab Example" width="300">
</div>
## Installation
```bash
pip install ipyformkit
```
For use in Google Colab one currently needs to downgrade ipywidgets as widgets are not displayed otherwise.
```bash
pip install ipyformkit
pip install "ipywidgets>=7,<8"
```
## Example Usage
```python
import ipyformkit as ifk
test = {'first name':'Zaphod',
'last name':'Beeblebrox',
('age', 'gender'):(-200, ('two-headed', 'male', 'female', 'non-binary')),
'height':2.05,
'date of birth':'Unknown (he probably lied about it anyway)',
('Input 1', 'Input 2', 'Input 3', 'Input 4'):('president', 'of', 'the', 'galaxy'),
('street', 'house'):('Heart of Gold Spaceship', 1),
'additional info':{'hobbies':'Kidnapping himself, avoiding responsibility, being outrageous',}
}
mandatory = ['last name', 'age']
disable = {'last name': lambda d: d['first name'] == '',}
hide = {'house': lambda d: d['street'] == '',}
check = {'age': lambda d: d['age'] > 0,}
tooltips = {'first name':'What your mother calls you when you are in trouble.'}
form = ifk.Form(test, title='Test Form', mandatory=mandatory, disable=disable, hide=hide, check=check, tooltips=tooltips, max_width=400)
form.display()
```
Text input is converted into placeholders instead of values by default. One can set multiple values at once by supplying a dictionary to the `.set_values()` method. The dictionary keys should match the field names in the form. The values can be any type supported by ipywidgets.
```python
form.set_values({'first name': 'Arthur', 'last name': 'Dent', 'age': 42})
```
Retrieve values:
```python
values = form.get_values() # returns unchecked values
out = form.check_and_return_values() # return checked values and highlights missing mandatory inputs
```
## Documentation
`ifk.Form()` is a class that creates a form using ipyipywidgets. It can be displayed using its `.display()` method. It takes a dictionary as input and generates the corresponding ipywidgets. The class also supports various features such as validation, conditional display, and custom styling. The arguments `mandatory`, `disable`, `hide` and `check` expect dictionaries with the affected field name as a key and a function as a value. The function takes the current form inputs as a dictionary and returns a boolean value. The function should return True if the field should be disabled, hidden or checked, and False otherwise. The `.get_values()` method returns the current values of each input field without applying any validation. The `.check_and_return_values()` method will return the current values but validate that all checks are passed.
| **Dictionary Value Type** | **Created Widget** | **Notes** |
|-----------------------------|--------------------------|----------------------------------------------------------------------------|
| `bool` | `ipywidgets.Checkbox` | A checkbox with the dictionary key as its description. |
| `int` | `ipywidgets.IntText` | A text box for integer input. |
| `float` | `ipywidgets.FloatText` | A text box for float input with step size based on decimal places. |
| `str` (contains `os.sep`) | `FileAutocomplete` | A custom widget for selecting files from the working directory. |
| `str` (contains "password") | `ipywidgets.Password` | A password input field. |
| `str` (ends with `...`) | `ipywidgets.Textarea` | A multi-line text area with the placeholder text (excluding `...`). |
| `str` (other cases) | `ipywidgets.Text` | A single-line text input field with the string as a placeholder. |
| `tuple` | `ipywidgets.Dropdown` | A dropdown menu with the tuple values as options. |
| `dictionary` | `...` | A collapsible sub-form with the dictionary mapped according to this table. |
| Other types | `ipywidgets.Label` | A label displaying "Unsupported type: <type_name>". |
Raw data
{
"_id": null,
"home_page": null,
"name": "ipyformkit",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "widgets, ipywidgets, form, Jupyter",
"author": "Richard Hoppe",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/ac/93/cbaae40ed71721a3147f327bdb84e50f3283c151e0439a547a4b678764d4/ipyformkit-0.2.2.tar.gz",
"platform": null,
"description": "# IpyFormKit\n\nIpyFormKit is a Python library for creating dynamic, interactive forms using `ipywidgets` in Jupyter notebooks. It simplifies the process of building forms for data entry, configuration, or experimentation with minimal code.\n\n## Features\n\n- **Dynamic Forms**: Automatically generate forms from dictionaries with support for various input types (text, numbers, dropdowns, checkboxes, etc.).\n- **Custom Widgets**: Includes specialized widgets like `FileAutocomplete` for file selection and `CollapsibleVBox` for collapsible sections.\n- **Validation and Logic**: Add conditions to disable, hide, or validate fields dynamically based on user input.\n- **Masonry Layout**: Organize multiple forms in a responsive masonry-style layout.\n- **Adaptive CSS Styling** Seamless integration with Jupyter Notebook/Lab, Google Colab and VScode themes.\n\n<div style=\"display: flex; justify-content: space-around;\">\n <img src=\"https://raw.githubusercontent.com/RMHoppe/IpyFormKit/refs/heads/main/images/jupyterlab-light.png\" alt=\"Jupyter Lab Light Example\" width=\"300\">\n <img src=\"https://raw.githubusercontent.com/RMHoppe/IpyFormKit/refs/heads/main/images/jupyterlab-dark.png\" alt=\"Jupyter Lab Dark Example\" width=\"300\">\n <img src=\"https://raw.githubusercontent.com/RMHoppe/IpyFormKit/refs/heads/main/images/vscode.png\" alt=\"VSCode Example\" width=\"300\">\n <img src=\"https://raw.githubusercontent.com/RMHoppe/IpyFormKit/refs/heads/main/images/googlecolab.png\" alt=\"Google Colab Example\" width=\"300\">\n</div>\n\n\n## Installation\n```bash\npip install ipyformkit\n```\n\nFor use in Google Colab one currently needs to downgrade ipywidgets as widgets are not displayed otherwise.\n```bash\npip install ipyformkit\npip install \"ipywidgets>=7,<8\"\n```\n\n## Example Usage\n```python\nimport ipyformkit as ifk\n\ntest = {'first name':'Zaphod',\n 'last name':'Beeblebrox',\n ('age', 'gender'):(-200, ('two-headed', 'male', 'female', 'non-binary')),\n 'height':2.05,\n 'date of birth':'Unknown (he probably lied about it anyway)',\n ('Input 1', 'Input 2', 'Input 3', 'Input 4'):('president', 'of', 'the', 'galaxy'),\n ('street', 'house'):('Heart of Gold Spaceship', 1),\n 'additional info':{'hobbies':'Kidnapping himself, avoiding responsibility, being outrageous',}\n }\n\n\nmandatory = ['last name', 'age']\ndisable = {'last name': lambda d: d['first name'] == '',}\nhide = {'house': lambda d: d['street'] == '',}\ncheck = {'age': lambda d: d['age'] > 0,}\ntooltips = {'first name':'What your mother calls you when you are in trouble.'}\n\nform = ifk.Form(test, title='Test Form', mandatory=mandatory, disable=disable, hide=hide, check=check, tooltips=tooltips, max_width=400)\nform.display()\n```\n\nText input is converted into placeholders instead of values by default. One can set multiple values at once by supplying a dictionary to the `.set_values()` method. The dictionary keys should match the field names in the form. The values can be any type supported by ipywidgets.\n\n```python\nform.set_values({'first name': 'Arthur', 'last name': 'Dent', 'age': 42})\n```\n\nRetrieve values:\n```python\nvalues = form.get_values() # returns unchecked values\nout = form.check_and_return_values() # return checked values and highlights missing mandatory inputs\n```\n\n## Documentation\n`ifk.Form()` is a class that creates a form using ipyipywidgets. It can be displayed using its `.display()` method. It takes a dictionary as input and generates the corresponding ipywidgets. The class also supports various features such as validation, conditional display, and custom styling. The arguments `mandatory`, `disable`, `hide` and `check` expect dictionaries with the affected field name as a key and a function as a value. The function takes the current form inputs as a dictionary and returns a boolean value. The function should return True if the field should be disabled, hidden or checked, and False otherwise. The `.get_values()` method returns the current values of each input field without applying any validation. The `.check_and_return_values()` method will return the current values but validate that all checks are passed.\n\n| **Dictionary Value Type** | **Created Widget** | **Notes** |\n|-----------------------------|--------------------------|----------------------------------------------------------------------------|\n| `bool` | `ipywidgets.Checkbox` | A checkbox with the dictionary key as its description. |\n| `int` | `ipywidgets.IntText` | A text box for integer input. |\n| `float` | `ipywidgets.FloatText` | A text box for float input with step size based on decimal places. |\n| `str` (contains `os.sep`) | `FileAutocomplete` | A custom widget for selecting files from the working directory. |\n| `str` (contains \"password\") | `ipywidgets.Password` | A password input field. |\n| `str` (ends with `...`) | `ipywidgets.Textarea` | A multi-line text area with the placeholder text (excluding `...`). |\n| `str` (other cases) | `ipywidgets.Text` | A single-line text input field with the string as a placeholder. |\n| `tuple` | `ipywidgets.Dropdown` | A dropdown menu with the tuple values as options. |\n| `dictionary` | `...` | A collapsible sub-form with the dictionary mapped according to this table. |\n| Other types | `ipywidgets.Label` | A label displaying \"Unsupported type: <type_name>\". |\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 RMHoppe\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.\n ",
"summary": "Easy form creation with ipywidgets in Jupyter",
"version": "0.2.2",
"project_urls": {
"Homepage": "https://github.com/RMHoppe/IpyFormKit"
},
"split_keywords": [
"widgets",
" ipywidgets",
" form",
" jupyter"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3d7c619bc9658541c2f20c64deaaf2a6e5f69a964312792498c2ba54390c8596",
"md5": "3a92aad1a6754758c09b5136496eb4bd",
"sha256": "14115032cf72675fbd0806113550d83c5bace423fc8e5c11f0ba5f5ffa2160d3"
},
"downloads": -1,
"filename": "ipyformkit-0.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "3a92aad1a6754758c09b5136496eb4bd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 13982,
"upload_time": "2025-07-09T08:31:23",
"upload_time_iso_8601": "2025-07-09T08:31:23.941914Z",
"url": "https://files.pythonhosted.org/packages/3d/7c/619bc9658541c2f20c64deaaf2a6e5f69a964312792498c2ba54390c8596/ipyformkit-0.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ac93cbaae40ed71721a3147f327bdb84e50f3283c151e0439a547a4b678764d4",
"md5": "7e95fa2db813cefe542b5bf84357730c",
"sha256": "50e88f9703ed9885f4d8f07f4b22e9c535ed8b93dd2563f9e8dc3f847f026f4f"
},
"downloads": -1,
"filename": "ipyformkit-0.2.2.tar.gz",
"has_sig": false,
"md5_digest": "7e95fa2db813cefe542b5bf84357730c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 14928,
"upload_time": "2025-07-09T08:31:25",
"upload_time_iso_8601": "2025-07-09T08:31:25.233605Z",
"url": "https://files.pythonhosted.org/packages/ac/93/cbaae40ed71721a3147f327bdb84e50f3283c151e0439a547a4b678764d4/ipyformkit-0.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-09 08:31:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "RMHoppe",
"github_project": "IpyFormKit",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "ipyformkit"
}