Easy form creation with ipywidgets in Jupyter
Project description
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
FileAutocompletefor file selection andCollapsibleVBoxfor 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.
Installation
pip install ipyformkit
For use in Google Colab one currently needs to downgrade ipywidgets as widgets are not displayed otherwise.
pip install ipyformkit
pip install "ipywidgets>=7,<8"
Adaptive CSS Styling
Seamless integration with Jupyter notebook, Jupyter Lab, Google Colab and VScode themes.
Example Usage
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 = ['first name', 'last name', 'age']
disable = {'last name': lambda d: d['first name'] == '',}
hide = {'house': lambda d: d['street'] == '',}
check = {'age': lambda d: d['age'] > 0,}
form = ifk.Form(test, title='Test Form', mandatory=mandatory, disable=disable, hide=hide, check=check, max_width=400)
form.display()
Documentation
ifk.Form() is a class that creates a form using ipywidgets. It can be displayed using its .display() method. It takes a dictionary as input and generates the corresponding widgets. 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ipyformkit-0.1.6.tar.gz.
File metadata
- Download URL: ipyformkit-0.1.6.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
951641293df718a97943433b719a3c7ae923d3a501d1f950fde66dba885ab8d1
|
|
| MD5 |
fe807541199114377ef27edae0abb8f3
|
|
| BLAKE2b-256 |
c94d9437c8b7a350ef6e8b0dc7f18ad82fa087ae0e4771599a79dc76e6acac9f
|
Provenance
The following attestation bundles were made for ipyformkit-0.1.6.tar.gz:
Publisher:
python-publish.yml on RMHoppe/IpyFormKit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipyformkit-0.1.6.tar.gz -
Subject digest:
951641293df718a97943433b719a3c7ae923d3a501d1f950fde66dba885ab8d1 - Sigstore transparency entry: 212856905
- Sigstore integration time:
-
Permalink:
RMHoppe/IpyFormKit@ab46641ab968bc9f73ee7359b945ee510514fca2 -
Branch / Tag:
refs/tags/v0.1.6-alpha - Owner: https://github.com/RMHoppe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ab46641ab968bc9f73ee7359b945ee510514fca2 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ipyformkit-0.1.6-py3-none-any.whl.
File metadata
- Download URL: ipyformkit-0.1.6-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17a094a52d5f613f52a5af61e9233ac654b60711b29133dff1175ad34a9c8eba
|
|
| MD5 |
88fc6c59d7ac27f903ea2108aeb36f2a
|
|
| BLAKE2b-256 |
12a891ef6ac1bb73aaf29a1fa8e88d30211158f9a0af332ca1df2da7c93809ff
|
Provenance
The following attestation bundles were made for ipyformkit-0.1.6-py3-none-any.whl:
Publisher:
python-publish.yml on RMHoppe/IpyFormKit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ipyformkit-0.1.6-py3-none-any.whl -
Subject digest:
17a094a52d5f613f52a5af61e9233ac654b60711b29133dff1175ad34a9c8eba - Sigstore transparency entry: 212856908
- Sigstore integration time:
-
Permalink:
RMHoppe/IpyFormKit@ab46641ab968bc9f73ee7359b945ee510514fca2 -
Branch / Tag:
refs/tags/v0.1.6-alpha - Owner: https://github.com/RMHoppe
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@ab46641ab968bc9f73ee7359b945ee510514fca2 -
Trigger Event:
release
-
Statement type: