[wx]Python event programming framework
Project description
fsleyes-props
=============
.. image:: https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/badges/master/build.svg
:target: https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/commits/master/
.. image:: https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/badges/master/coverage.svg
:target: https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/commits/master/
.. image:: https://img.shields.io/pypi/v/fsleyes-props.svg
:target: https://pypi.python.org/pypi/fsleyes-props/)
``fsleyes-props`` is a library which is used by used by `FSLeyes
<https://git.fmrib.ox.ac.uk/fsl/fsleyes/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 :class:`.HasProperties` class,
and add some :class:`.PropertyBase` types as class attributes.
Dependencies
------------
All of the dependencies of ``fsleyes-props`` are listed in the
`requirements.txt <requirements.txt>`_ file. ``fsleyes-props`` can be used
without wxPython, but GUI functionality will not be available.
Documentation
-------------
``fsleyes-props`` is documented using `sphinx
<http://http://sphinx-doc.org/>`_. You can build the API documentation by
running::
python setup.py doc
The HTML documentation will be generated and saved in the ``doc/html/``
directory.
Example usage
-------------
.. code-block:: python
>>> 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
<https://git.fmrib.ox.ac.uk/fsl/fslpy/blob/master/doc/contributing.rst>`_.
=============
.. image:: https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/badges/master/build.svg
:target: https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/commits/master/
.. image:: https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/badges/master/coverage.svg
:target: https://git.fmrib.ox.ac.uk/fsl/fsleyes/props/commits/master/
.. image:: https://img.shields.io/pypi/v/fsleyes-props.svg
:target: https://pypi.python.org/pypi/fsleyes-props/)
``fsleyes-props`` is a library which is used by used by `FSLeyes
<https://git.fmrib.ox.ac.uk/fsl/fsleyes/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 :class:`.HasProperties` class,
and add some :class:`.PropertyBase` types as class attributes.
Dependencies
------------
All of the dependencies of ``fsleyes-props`` are listed in the
`requirements.txt <requirements.txt>`_ file. ``fsleyes-props`` can be used
without wxPython, but GUI functionality will not be available.
Documentation
-------------
``fsleyes-props`` is documented using `sphinx
<http://http://sphinx-doc.org/>`_. You can build the API documentation by
running::
python setup.py doc
The HTML documentation will be generated and saved in the ``doc/html/``
directory.
Example usage
-------------
.. code-block:: python
>>> 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
<https://git.fmrib.ox.ac.uk/fsl/fslpy/blob/master/doc/contributing.rst>`_.
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
fsleyes-props-1.2.3.tar.gz
(109.3 kB
view details)
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.2.3.tar.gz.
File metadata
- Download URL: fsleyes-props-1.2.3.tar.gz
- Upload date:
- Size: 109.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21bdbb6db84508ef2d477a102fd126184311676325179a170bbb7e6dca8c100d
|
|
| MD5 |
627e1258deeb872a7dc87a9133d7be37
|
|
| BLAKE2b-256 |
da6586d14ac7073283d846e31ec78aca031bd29916327ea07c2d199c68dfc738
|
File details
Details for the file fsleyes_props-1.2.3-py2.py3-none-any.whl.
File metadata
- Download URL: fsleyes_props-1.2.3-py2.py3-none-any.whl
- Upload date:
- Size: 103.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2605999ecb7be3caac1e28fe312950386432937b7a1c6630feb1b1ef47317d68
|
|
| MD5 |
4a69c69a06942cca947e67eafd1cc33b
|
|
| BLAKE2b-256 |
a406f7f3492a2241287904474b698e8a3ecca678bbfb270f32edd6df9cea1dbf
|