[wx]Python event programming framework
Project description
fsleyes-props is a library which is used by used by FSLeyes, and which allows you to:
Listen for change to attributes on a python object,
Automatically generate wxpython widgets which are bound to attributes of a python object
Automatically generate a command line interface to set values of the attributes of a python object.
To do this, you just need to subclass the fsleyes)props.HasProperties class (also available as fsleyes_props.Props), and add some PropertyBase types as class attributes.
Installation
You can install fsleyes-props via pip. If you are using Linux, you need to install wxPython first, as binaries are not available on PyPI. Change the URL for your specific platform:
pip install -f https://extras.wxpython.org/wxPython4/extras/linux/gtk2/ubuntu-16.04/ wxpython
Then install fsleyes-props like so:
pip install fsleyes-props
fsleyes-props is also available on conda-forge:
conda install -c conda-forge fsleyes-props
Dependencies
All of the dependencies of fsleyes-props are listed in the requirements.txt file. fsleyes-props can be used without wxPython, but GUI functionality will not be available.
Dependencies for running the tests and building documentation are listed in the requirements-dev.txt file.
Documentation
The fsleyes-props API documentation is hosted at https://open.win.ox.ac.uk/pages/fsl/fsleyes/props/.
fsleyes-props is documented using sphinx. You can build the API documentation by running:
pip install -r requirements-dev.txt python setup.py doc
The HTML documentation will be generated and saved in the doc/html/ directory.
Tests
Run the test suite via:
pip install -r requirements-dev.txt python setup.py test
Many of the tests assume that a display is accessible - if you are running on a headless machine, you may need to run the tests using xvfb-run.
Example usage
>>> import fsleyes_props as props
>>>
>>> class PropObj(props.Props):
>>> myProperty = props.Boolean()
>>>
>>> myPropObj = PropObj()
>>>
>>> # Access the property value as a normal attribute:
>>> myPropObj.myProperty = True
>>> myPropObj.myProperty
True
>>>
>>> # Receive notification of property value changes
>>> def myPropertyChanged(value, *args):
>>> print(f'New property value: {value}')
>>>
>>> myPropObj.listen('myProperty', 'myListener', myPropertyChanged)
>>>
>>> myPropObj.myProperty = False
New property value: False
>>>
>>> # Remove a previously added listener
>>> myPropObj.remove('myListener')
Contributing
If you would like to contribute to fsleyes-props, take a look at the fslpy contributing guide.
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 fsleyes-props-1.9.3.tar.gz.
File metadata
- Download URL: fsleyes-props-1.9.3.tar.gz
- Upload date:
- Size: 116.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7bf2844b9d0dc710343a3ce667d121fd0180d9ff31503d0bb093a723c2e8b34d
|
|
| MD5 |
e294ff815530561ac87e4290bdcc4ff8
|
|
| BLAKE2b-256 |
a1164734d0eab0a5b8158144e82748f6e36812d8ab8a60208a214376d96d31df
|
File details
Details for the file fsleyes_props-1.9.3-py2.py3-none-any.whl.
File metadata
- Download URL: fsleyes_props-1.9.3-py2.py3-none-any.whl
- Upload date:
- Size: 105.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38b0d5283966b2c92efdc5ad7f43c1d6a7f61704d367a4d4f8c5f16e1189bf7b
|
|
| MD5 |
4c9921ea42b8370dc7034d992460d894
|
|
| BLAKE2b-256 |
7df16be84a6d26994368dd8321dde05a70dcd87f5df34d143ab9e7a642110875
|