A python package to define how a class member should be rendered in a UI.
Project description
propsettings
This packages enables you to decorate class member variables as a Setting. A Setting is a kind of property that let you define some characteristics of the variable that are taken into account by a user interface code to render that variable properly.
Usage
To register a member variable as a Setting you must use the method register_as_setting
, e.g.
from propsettings.configurable import register_as_setting
class Example:
def __init__():
self._variable = 4
register_as_setting(Example, "_variable")
You can specify the label the UI will show for that variable with
register_as_setting(Example, "_variable", label="Variable label")
When the variable you want to decorate is initialized with None you must also specify the data type
class Example:
def __init__():
self._variable = None
register_as_setting(Example, "_variable", setting_value_type=str)
Sometimes is desirable to draw (in the user interface) your variable in a different way than the default. For example, the default way to show an integer value is with a text edit validated to only accept numeric values. However, maybe your variable only makes sense in the range [0 , 10]. In that case is better to have a slider than a text edit. That is when setting types come into play. A setting type is a type of annotation that gives more information about how to draw and validate a variable. For example:
register_as_setting(Example, "_variable", setting_type=Range(0, 10))
To get a list of an object settings you can use
from propsettings.configurable import get_settings
e = Example()
settings = get_settings(e)
How to draw UI
This package is for variable annotation only. In order to draw user interfaces that take into account this annotations to render the variables you annotate, you must use another library. For Qt aaplications there is propsettings_qt
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
File details
Details for the file propsettings-0.1.11.tar.gz
.
File metadata
- Download URL: propsettings-0.1.11.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 62066763f234c2db3f25f8959e919b8ce19d58e43151b92beb463741ac43d6c8 |
|
MD5 | b44e86e9ce0b2c423f5e574f464b8327 |
|
BLAKE2b-256 | b0c5decbcf750e045f61ee95d84ead15bb70f5bc7224d84285f51b847e332331 |
File details
Details for the file propsettings-0.1.11-py3-none-any.whl
.
File metadata
- Download URL: propsettings-0.1.11-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37a1f41dfe915125daaba26a2fbd5d19c2d90eba2ad4c1670b53e325cdf81c26 |
|
MD5 | d426f4f9546881f605c1242e0fef5599 |
|
BLAKE2b-256 | 1a4dfc3803b29106cd73d597d63d8b15c1d675f1c81ebe28d33de0b06f64c808 |