Skip to main content

[wx]Python event programming framework

Project description

https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/badges/master/pipeline.svg https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/badges/master/coverage.svg https://img.shields.io/pypi/v/fsleyes-props.svg https://anaconda.org/conda-forge/fsleyes-props/badges/version.svg

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 pyproject.toml 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 as extra test and doc dependencies, and can be installed with pip like so:

pip install fsleyes-props[doc,test]

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:

sphinx-build doc html

The HTML documentation will be generated and saved in the html/ directory.

Tests

Run the test suite via:

pytest

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


Download files

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

Source Distribution

fsleyes_props-1.12.0.tar.gz (121.8 kB view details)

Uploaded Source

Built Distribution

fsleyes_props-1.12.0-py3-none-any.whl (128.0 kB view details)

Uploaded Python 3

File details

Details for the file fsleyes_props-1.12.0.tar.gz.

File metadata

  • Download URL: fsleyes_props-1.12.0.tar.gz
  • Upload date:
  • Size: 121.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for fsleyes_props-1.12.0.tar.gz
Algorithm Hash digest
SHA256 c1ed2e958bf5e6bf63488a0e931a330709644737b0bb653c0c85796ebc275c7b
MD5 d77e9746ad9f63422777f7802a0a5e13
BLAKE2b-256 81d5c58f0d130bcba35f9c3ee3d49ca279ead1a6aef8700e580a2a808974e4e8

See more details on using hashes here.

File details

Details for the file fsleyes_props-1.12.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fsleyes_props-1.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 daf7c44c5fc7299377227e976f99641059783f7fc4783385ec329d98c834949f
MD5 c37eeb905b819d2b9945f6839bf09e45
BLAKE2b-256 a5b9855c772bf85721e45d71397b83e8eae250ebec84598780bd61c1486bcc76

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