Library for building dynamic forms
Project description
opengui
Library for building dynamic forms, forms whose options and even fields change based on values in other fields.
This doesn't involve rendering dynamic forms, just making creating and altering the structures thereof.
Example
# Create a single multi select field
fields = opengui.Fields(
values=values, # Values of the fields in key:value dict.
fields=[
{
"name": "types",
"options": [
"textarea",
"options",
"fields"
],
"multi": True,
"trigger": True
}
]
)
# If they select textarea, add it
if "textarea" in (fields["types"].value or []):
fields.append({
"name": "people",
"style": "textarea"
})
fields.ready = True
# If they selected option, add a format, then check what format they selected
if "options" in (fields["types"].value or []):
fields.append({
"name": "style",
"options": [
"radios",
"select"
],
"default": "radios",
"trigger": True
})
fields.append({
"name": "stuff",
"options": [
"fee",
"fie",
"foe",
"fum"
],
"style": fields["style"].value
})
fields.ready = True
# If they add subfields, add two, and make the second optional
if "fields" in (fields["types"].value or []):
fields.append({
"name": "things",
"fields": [
{
"name": "yin",
},
{
"name": "yang",
"optional": True
}
]
})
fields.ready = True
# Retrn as a dict
return fields.to_dict(), 200
More here
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
opengui-0.9.4.tar.gz
(8.6 kB
view details)
Built Distribution
File details
Details for the file opengui-0.9.4.tar.gz
.
File metadata
- Download URL: opengui-0.9.4.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1680462c6098bb98e14161580b9343f366ff8e0b76240dc187b600f704df4552 |
|
MD5 | 178bf13488693f5c99936fc6f2b2c2a8 |
|
BLAKE2b-256 | 956fa94d5f3aa93909d0a34e2c8bdd71d360f2bfea8c7fc058c973496737eb41 |
File details
Details for the file opengui-0.9.4-py3-none-any.whl
.
File metadata
- Download URL: opengui-0.9.4-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f8dd402de81da266f8f1272f706f14692fe162ed668e360a3d5a6965b2f8ecb |
|
MD5 | 6fc0071535752887796fab2af84793d8 |
|
BLAKE2b-256 | 7fd5d1a7955f66b7fda4d64e4aa6720c98637c0626741bd2542b3eb362fba2e2 |