Skip to main content

[wx]Python event programming framework

Project description

https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/badges/master/build.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 HasProperties class, 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

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.HasProperties):
>>>     myProperty = props.Boolean()
>>>
>>> myPropObj = PropObj()
>>>
>>> # Access the property value as a normal attribute:
>>> myPropObj.myProperty = True
>>> myPropObj.myProperty
True
>>>
>>> # access the props.Boolean instance:
>>> myPropObj.getProp('myProperty')
<props.prop.Boolean at 0x1045e2710>
>>>
>>> # access the underlying props.PropertyValue object
>>> # (there are caveats for List properties):
>>> myPropObj.getPropVal('myProperty')
<props.prop.PropertyValue instance at 0x1047ef518>
>>>
>>> # Receive notification of property value changes
>>> def myPropertyChanged(value, *args):
>>>     print('New property value: {}'.format(value))
>>>
>>> myPropObj.addListener(
>>>    'myProperty', 'myListener', myPropertyChanged)
>>>
>>> myPropObj.myProperty = False
New property value: False
>>>
>>> # Remove a previously added listener
>>> myPropObj.removeListener('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.7.1.tar.gz (114.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fsleyes_props-1.7.1-py2.py3-none-any.whl (105.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file fsleyes-props-1.7.1.tar.gz.

File metadata

  • Download URL: fsleyes-props-1.7.1.tar.gz
  • Upload date:
  • Size: 114.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for fsleyes-props-1.7.1.tar.gz
Algorithm Hash digest
SHA256 c2a037e28200dd97f2d2f41d420cf286b109b125e850a4ad57f3778c5cb859de
MD5 e131a8a70613b65e068944a9a9341353
BLAKE2b-256 b70074bf0aee91c51ff4488b9211471e5985130e8d06f9b0708a6d4f68805d97

See more details on using hashes here.

File details

Details for the file fsleyes_props-1.7.1-py2.py3-none-any.whl.

File metadata

  • Download URL: fsleyes_props-1.7.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 105.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for fsleyes_props-1.7.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7da650a09a8456d7870f625e6f40daeb227ce646c4a797f8bb7e66cdd6baafeb
MD5 3a99471c7063f884ed1ddea0fe6e96d3
BLAKE2b-256 0269077ac7a781457fc991a4700f48d0aac6ffc58cee82868ee542b51c0d8ea3

See more details on using hashes here.

Supported by

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