Skip to main content

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 type of property that allows defining characteristics of a variable that are taken into account by a user interface code to render that variable properly.

Installation

pip install propsettings

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:

from propsettings.setting_types.range_setting_type import Range

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

propsettings-0.1.14.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

propsettings-0.1.14-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file propsettings-0.1.14.tar.gz.

File metadata

  • Download URL: propsettings-0.1.14.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for propsettings-0.1.14.tar.gz
Algorithm Hash digest
SHA256 40afcf1e4cbb5744d9b8dd6868e18ce287cad7abb51de102fad4932f9476ec15
MD5 7e6142c98611f3675680b6406b3bb1e4
BLAKE2b-256 68627336bb50b80d480389a9b55e689f9a42a55b85dc4b7a56bb0a3010578c3e

See more details on using hashes here.

File details

Details for the file propsettings-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: propsettings-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for propsettings-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 70a4c65120ee10e617f4eec73e433de3eba55b3c9a89211f799b658cd02a87a0
MD5 8f9c72a250505fda6de0360685c708e9
BLAKE2b-256 d9de4409e3b574b3e1d62acad96cc3861a616f2481f126108dfb624b05fbf40d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page