Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FSL
fsleyes
fsleyes-props
Commits
3ac5dadc
Commit
3ac5dadc
authored
Aug 27, 2017
by
Paul McCarthy
🚵
Browse files
All mentions of 'constraints' replaced with 'attributes'
parent
368c5c36
Changes
9
Hide whitespace changes
Inline
Side-by-side
fsleyes_props/__init__.py
View file @
3ac5dadc
...
...
@@ -155,15 +155,15 @@ set.
The default validation logic of most ``PropertyBase`` objects can be
configured via *
constraint
s*. For example, the :class:`.Number` property
allows ``minval`` and ``maxval``
constraint
s to be set. These may be set via
configured via *
attribute
s*. For example, the :class:`.Number` property
allows ``minval`` and ``maxval``
attribute
s to be set. These may be set via
``PropertyBase`` constructors, (i.e. when it is defined as a class attribute
of a ``HasProperties`` definition), and may be queried and changed on
individual ``HasProperties`` instances via the
:meth:`.HasProperties.get
Constraint
`/:meth:`.HasProperties.set
Constraint
`
:meth:`.HasProperties.get
Attribute
`/:meth:`.HasProperties.set
Attribute
`
methods; similarly named methods are also available on ``PropertyBase``
instances. Some ``PropertyBase`` classes provide additional convenience
methods for accessing their
constraint
s (e.g. :meth`.Choice.addChoice`).
methods for accessing their
attribute
s (e.g. :meth`.Choice.addChoice`).
^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
...
@@ -290,7 +290,7 @@ notification of properties to be suppressed in a ``with`` statement.
"""
__version__
=
'1.
1.3
.dev'
__version__
=
'1.
2.0
.dev'
import
sys
...
...
fsleyes_props/cli.py
View file @
3ac5dadc
...
...
@@ -257,7 +257,7 @@ def _Choice(parser,
will be configured to accept any value.
:arg default: If not ``None``, gives the default value. Otherwise,
the ``default``
constraint
of the :class:`.Choice`
the ``default``
attribute
of the :class:`.Choice`
object is used.
:arg useAlts: If ``True`` (the default), alternate values for the
...
...
@@ -285,7 +285,7 @@ def _Choice(parser,
choices
+=
[
a
for
a
in
altList
]
if
default
is
None
:
default
=
propObj
.
get
Constraint
(
None
,
'default'
)
default
=
propObj
.
get
Attribute
(
None
,
'default'
)
# Make sure that only unique
# choices are set as options.
...
...
fsleyes_props/properties.py
View file @
3ac5dadc
...
...
@@ -86,7 +86,7 @@ class PropertyBase(object):
equalityFunc
=
None
,
required
=
False
,
allowInvalid
=
True
,
**
constrain
ts
):
**
at
ts
):
"""Define a ``PropertyBase`` property.
:param default: Default/initial value.
...
...
@@ -100,7 +100,7 @@ class PropertyBase(object):
:param validateFunc: Custom validation function. Must accept three
parameters: a reference to the ``HasProperties``
instance, the owner of this property; a
dictionary containing the
constraint
s for this
dictionary containing the
attribute
s for this
property; and the new property value. Should
return ``True`` if the property value is valid,
``False`` otherwise.
...
...
@@ -114,25 +114,25 @@ class PropertyBase(object):
invalid - see caveats in the
:class:`.PropertyValue` documentation.
:param
constraints:
Type specific
constraint
s used to test
:param
atts:
Type specific
attribute
s used to test
validity - passed to the
:meth:`.PropertyValue.__init__` method as
its ``attributes``.
"""
constrain
ts
[
'default'
]
=
default
constrain
ts
[
'enabled'
]
=
constrain
ts
.
get
(
'enabled'
,
True
)
at
ts
[
'default'
]
=
default
at
ts
[
'enabled'
]
=
at
ts
.
get
(
'enabled'
,
True
)
# A _label is added to this dict by the
# PropertyOwner metaclass for each new
# HasProperties class that is defined
self
.
_label
=
{}
self
.
_required
=
required
self
.
_validateFunc
=
validateFunc
self
.
_equalityFunc
=
equalityFunc
self
.
_allowInvalid
=
allowInvalid
self
.
_default
Constraints
=
constrain
ts
self
.
_required
=
required
self
.
_validateFunc
=
validateFunc
self
.
_equalityFunc
=
equalityFunc
self
.
_allowInvalid
=
allowInvalid
self
.
_default
Attributes
=
at
ts
def
__copy__
(
self
):
...
...
@@ -149,8 +149,8 @@ class PropertyBase(object):
newProp
.
_label
=
{}
# Give the new object an independent
# default
Constraint
dictionary
newProp
.
_default
Constraint
s
=
dict
(
newProp
.
_default
Constraint
s
)
# default
Attributes
dictionary
newProp
.
_default
Attribute
s
=
dict
(
newProp
.
_default
Attribute
s
)
return
newProp
...
...
@@ -319,7 +319,7 @@ class PropertyBase(object):
"""Creates and returns a ``PropertyValue`` object for the given
``HasProperties`` instance.
"""
default
=
self
.
_default
Constraint
s
.
get
(
'default'
,
None
)
default
=
self
.
_default
Attribute
s
.
get
(
'default'
,
None
)
return
properties_value
.
PropertyValue
(
instance
,
name
=
self
.
getLabel
(
instance
),
value
=
default
,
...
...
@@ -327,7 +327,7 @@ class PropertyBase(object):
validateFunc
=
self
.
validate
,
equalityFunc
=
self
.
_equalityFunc
,
allowInvalid
=
self
.
_allowInvalid
,
**
self
.
_default
Constraint
s
)
**
self
.
_default
Attribute
s
)
def
validate
(
self
,
instance
,
attributes
,
value
):
...
...
@@ -360,8 +360,7 @@ class PropertyBase(object):
:param dict attributes: Attributes of the ``PropertyValue`` object,
which are used to store type-specific
constraints for ``PropertyBase``
subclasses.
attributes for ``PropertyBase`` subclasses.
:param value: The value to be validated.
"""
...
...
@@ -469,7 +468,7 @@ class ListPropertyBase(PropertyBase):
itemValidateFunc
=
self
.
_listType
.
validate
itemEqualityFunc
=
self
.
_listType
.
_equalityFunc
itemAllowInvalid
=
self
.
_listType
.
_allowInvalid
itemAttributes
=
self
.
_listType
.
_default
Constraint
s
itemAttributes
=
self
.
_listType
.
_default
Attribute
s
else
:
itemCastFunc
=
None
itemValidateFunc
=
None
...
...
@@ -477,7 +476,7 @@ class ListPropertyBase(PropertyBase):
itemAllowInvalid
=
True
itemAttributes
=
None
default
=
self
.
_default
Constraint
s
.
get
(
'default'
,
None
)
default
=
self
.
_default
Attribute
s
.
get
(
'default'
,
None
)
return
properties_value
.
PropertyValueList
(
instance
,
...
...
@@ -488,7 +487,7 @@ class ListPropertyBase(PropertyBase):
itemEqualityFunc
=
itemEqualityFunc
,
listValidateFunc
=
self
.
validate
,
itemAllowInvalid
=
itemAllowInvalid
,
listAttributes
=
self
.
_default
Constraint
s
,
listAttributes
=
self
.
_default
Attribute
s
,
itemAttributes
=
itemAttributes
)
...
...
@@ -912,7 +911,7 @@ class HasProperties(six.with_metaclass(PropertyOwner, object)):
details
=
'Use getAttribute instead'
)
def
getConstraint
(
self
,
propName
,
constraint
):
"""See :meth:`getAttribute`. """
return
self
.
get
Prop
(
propName
).
getConstraint
(
self
,
constraint
)
return
self
.
get
Attribute
(
propName
,
constraint
)
@
deprecation
.
deprecated
(
deprecated_in
=
'1.2.0'
,
...
...
@@ -920,7 +919,7 @@ class HasProperties(six.with_metaclass(PropertyOwner, object)):
details
=
'Use setAttribute instead'
)
def
setConstraint
(
self
,
propName
,
constraint
,
value
):
"""See :meth:`setAttribute`. """
return
self
.
g
et
Prop
(
propName
).
setConstraint
(
self
,
constraint
,
value
)
return
self
.
s
et
Attribute
(
propName
,
constraint
,
value
)
def
getAttribute
(
self
,
propName
,
*
args
):
...
...
fsleyes_props/properties_types.py
View file @
3ac5dadc
...
...
@@ -137,7 +137,7 @@ class Number(props.PropertyBase):
:param instance: The owning :class:`.HasProperties` instance (or
``None`` for unbound property values).
:param attributes: Dictionary containing property
constraint
s.
:param attributes: Dictionary containing property
attribute
s.
:param value: The value to validate.
"""
...
...
@@ -157,7 +157,7 @@ class Number(props.PropertyBase):
def
cast
(
self
,
instance
,
attributes
,
value
):
"""Overrides :meth:`.PropertyBase.cast`.
If the ``clamped``
constraint
is ``True`` and the ``minval`` and/or
If the ``clamped``
attribute
is ``True`` and the ``minval`` and/or
``maxval`` have been set, this function ensures that the given value
lies within the ``minval`` and ``maxval`` limits. Otherwise the value
is returned unchanged.
...
...
@@ -273,7 +273,7 @@ class String(props.PropertyBase):
Passes the given value to
:meth:`.PropertyBase.validate`. Then, if either the
``minlen`` or ``maxlen``
constraint
s have been set, and the given
``minlen`` or ``maxlen``
attribute
s have been set, and the given
value has length less than ``minlen`` or greater than ``maxlen``,
raises a :exc:`ValueError`.
"""
...
...
@@ -399,43 +399,43 @@ class Choice(props.PropertyBase):
if
default
not
in
self
.
getChoices
(
instance
):
raise
ValueError
(
'{} is not a choice'
.
format
(
default
))
self
.
set
Constraint
(
instance
,
'default'
,
default
)
self
.
set
Attribute
(
instance
,
'default'
,
default
)
def
enableChoice
(
self
,
choice
,
instance
=
None
):
"""Enables the given choice. """
choiceEnabled
=
dict
(
self
.
get
Constraint
(
instance
,
'choiceEnabled'
))
choiceEnabled
=
dict
(
self
.
get
Attribute
(
instance
,
'choiceEnabled'
))
choiceEnabled
[
choice
]
=
True
self
.
set
Constraint
(
instance
,
'choiceEnabled'
,
choiceEnabled
)
self
.
set
Attribute
(
instance
,
'choiceEnabled'
,
choiceEnabled
)
def
disableChoice
(
self
,
choice
,
instance
=
None
):
"""Disables the given choice. An attempt to set the property to
a disabled value will result in a :exc:`ValueError`.
"""
choiceEnabled
=
dict
(
self
.
get
Constraint
(
instance
,
'choiceEnabled'
))
choiceEnabled
=
dict
(
self
.
get
Attribute
(
instance
,
'choiceEnabled'
))
choiceEnabled
[
choice
]
=
False
self
.
set
Constraint
(
instance
,
'choiceEnabled'
,
choiceEnabled
)
self
.
set
Attribute
(
instance
,
'choiceEnabled'
,
choiceEnabled
)
def
choiceEnabled
(
self
,
choice
,
instance
=
None
):
"""Returns ``True`` if the given choice is enabled, ``False``
otherwise.
"""
return
self
.
get
Constraint
(
instance
,
'choiceEnabled'
)[
choice
]
return
self
.
get
Attribute
(
instance
,
'choiceEnabled'
)[
choice
]
def
getChoices
(
self
,
instance
=
None
):
"""Returns a list of the current choices. """
return
list
(
self
.
get
Constraint
(
instance
,
'choices'
))
return
list
(
self
.
get
Attribute
(
instance
,
'choices'
))
def
getAlternates
(
self
,
instance
=
None
):
"""Returns a list of the current acceptable alternate values for each
choice.
"""
choices
=
self
.
get
Constraint
(
instance
,
'choices'
)
altLists
=
self
.
get
Constraint
(
instance
,
'altLists'
)
choices
=
self
.
get
Attribute
(
instance
,
'choices'
)
altLists
=
self
.
get
Attribute
(
instance
,
'altLists'
)
return
[
altLists
[
c
]
for
c
in
choices
]
...
...
@@ -448,8 +448,8 @@ class Choice(props.PropertyBase):
"""Updates the choice value and/or alternates for the specified choice.
"""
choices
=
list
(
self
.
get
Constraint
(
instance
,
'choices'
))
altLists
=
dict
(
self
.
get
Constraint
(
instance
,
'altLists'
))
choices
=
list
(
self
.
get
Attribute
(
instance
,
'choices'
))
altLists
=
dict
(
self
.
get
Attribute
(
instance
,
'altLists'
))
idx
=
choices
.
index
(
choice
)
if
newChoice
is
not
None
:
...
...
@@ -479,7 +479,7 @@ class Choice(props.PropertyBase):
# Add stringified versions of all
# choices if allowStr is True
if
self
.
get
Constraint
(
instance
,
'allowStr'
):
if
self
.
get
Attribute
(
instance
,
'allowStr'
):
for
c
in
choices
:
strc
=
str
(
c
)
alts
=
alternates
[
c
]
...
...
@@ -498,10 +498,10 @@ class Choice(props.PropertyBase):
if
alternate
is
None
:
alternate
=
[]
else
:
alternate
=
list
(
alternate
)
choices
=
list
(
self
.
get
Constraint
(
instance
,
'choices'
))
altLists
=
dict
(
self
.
get
Constraint
(
instance
,
'altLists'
))
choices
=
list
(
self
.
get
Attribute
(
instance
,
'choices'
))
altLists
=
dict
(
self
.
get
Attribute
(
instance
,
'altLists'
))
if
self
.
get
Constraint
(
instance
,
'allowStr'
):
if
self
.
get
Attribute
(
instance
,
'allowStr'
):
strc
=
str
(
choice
)
if
strc
not
in
alternate
:
alternate
.
append
(
strc
)
...
...
@@ -515,8 +515,8 @@ class Choice(props.PropertyBase):
def
removeChoice
(
self
,
choice
,
instance
=
None
):
"""Removes the specified choice from the list of possible choices. """
choices
=
list
(
self
.
get
Constraint
(
instance
,
'choices'
))
altLists
=
dict
(
self
.
get
Constraint
(
instance
,
'altLists'
))
choices
=
list
(
self
.
get
Attribute
(
instance
,
'choices'
))
altLists
=
dict
(
self
.
get
Attribute
(
instance
,
'altLists'
))
choices
.
remove
(
choice
)
altLists
.
pop
(
choice
)
...
...
@@ -553,9 +553,9 @@ class Choice(props.PropertyBase):
:param alternates: A dict of ``{choice : [alternates]}`` mappings.
"""
propVal
=
self
.
getPropVal
(
instance
)
default
=
self
.
get
Constraint
(
instance
,
'default'
)
oldEnabled
=
self
.
get
Constraint
(
instance
,
'choiceEnabled'
)
propVal
=
self
.
getPropVal
(
instance
)
default
=
self
.
get
Attribute
(
instance
,
'default'
)
oldEnabled
=
self
.
get
Attribute
(
instance
,
'choiceEnabled'
)
newEnabled
=
{}
# Prevent notification while
...
...
@@ -577,11 +577,11 @@ class Choice(props.PropertyBase):
altLists
=
alternates
alternates
=
self
.
__generateAlternatesDict
(
altLists
)
self
.
set
Constraint
(
instance
,
'choiceEnabled'
,
newEnabled
)
self
.
set
Constraint
(
instance
,
'altLists'
,
altLists
)
self
.
set
Constraint
(
instance
,
'alternates'
,
alternates
)
self
.
set
Constraint
(
instance
,
'choices'
,
choices
)
self
.
set
Constraint
(
instance
,
'default'
,
default
)
self
.
set
Attribute
(
instance
,
'choiceEnabled'
,
newEnabled
)
self
.
set
Attribute
(
instance
,
'altLists'
,
altLists
)
self
.
set
Attribute
(
instance
,
'alternates'
,
alternates
)
self
.
set
Attribute
(
instance
,
'choices'
,
choices
)
self
.
set
Attribute
(
instance
,
'default'
,
default
)
if
propVal
is
not
None
:
...
...
@@ -608,9 +608,9 @@ class Choice(props.PropertyBase):
"""
props
.
PropertyBase
.
validate
(
self
,
instance
,
attributes
,
value
)
choices
=
self
.
get
Constraint
(
instance
,
'choices'
)
enabled
=
self
.
get
Constraint
(
instance
,
'choiceEnabled'
)
alternates
=
self
.
get
Constraint
(
instance
,
'alternates'
)
choices
=
self
.
get
Attribute
(
instance
,
'choices'
)
enabled
=
self
.
get
Attribute
(
instance
,
'choiceEnabled'
)
alternates
=
self
.
get
Attribute
(
instance
,
'alternates'
)
if
len
(
choices
)
==
0
:
return
...
...
@@ -631,7 +631,7 @@ class Choice(props.PropertyBase):
Checks to see if the given value is a valid alternate value for a
choice. If so, the alternate value is replaced with the choice value.
"""
alternates
=
self
.
get
Constraint
(
instance
,
'alternates'
)
alternates
=
self
.
get
Attribute
(
instance
,
'alternates'
)
return
alternates
.
get
(
value
,
value
)
...
...
@@ -667,7 +667,7 @@ class FilePath(String):
def
validate
(
self
,
instance
,
attributes
,
value
):
"""Overrides :meth:`.PropertyBase.validate`.
If the ``exists``
constraint
is not ``True``, does nothing. Otherwise,
If the ``exists``
attribute
is not ``True``, does nothing. Otherwise,
if ``isFile`` is ``False`` and the given value is not a path to an
existing directory, a :exc:`ValueError` is raised.
...
...
@@ -748,7 +748,7 @@ class List(props.ListPropertyBase):
"""Overrides :meth:`.PropertyBase.validate`.
Checks that the given value (which should be a list) meets the
``minlen``/``maxlen``
constraints
. Raises a :exc:`ValueError` if it
``minlen``/``maxlen``
attribute
. Raises a :exc:`ValueError` if it
does not.
"""
...
...
@@ -816,7 +816,7 @@ class Colour(props.PropertyBase):
pv
=
self
.
getPropVal
(
instance
)
if
pv
is
not
None
:
currentVal
=
pv
.
get
()
else
:
currentVal
=
self
.
_defaultConstraints
[
'default'
]
else
:
currentVal
=
self
.
getAttribute
(
None
,
'default'
)
value
=
[
float
(
v
)
for
v
in
value
]
...
...
@@ -871,13 +871,13 @@ class ColourMap(props.PropertyBase):
:arg cmaps: a list of registered colour map names.
"""
default
=
self
.
get
Constraint
(
instance
,
'default'
)
default
=
self
.
get
Attribute
(
instance
,
'default'
)
if
default
not
in
cmaps
:
default
=
cmaps
[
0
]
self
.
set
Constraint
(
instance
,
'cmaps'
,
cmaps
)
self
.
set
Constraint
(
instance
,
'default'
,
default
)
self
.
set
Attribute
(
instance
,
'cmaps'
,
cmaps
)
self
.
set
Attribute
(
instance
,
'default'
,
default
)
def
addColourMap
(
self
,
cmap
,
instance
=
None
):
...
...
@@ -897,7 +897,7 @@ class ColourMap(props.PropertyBase):
"""Returns a list containing the names of registered colour maps
available for this property.
"""
return
list
(
self
.
get
Constraint
(
instance
,
'cmaps'
))
return
list
(
self
.
get
Attribute
(
instance
,
'cmaps'
))
def
validate
(
self
,
instance
,
attributes
,
value
):
...
...
@@ -958,12 +958,12 @@ class BoundsValueList(propvals.PropertyValueList):
``PropertyValueList`` base class. For a single dimension, a bound
object has a ``lo`` value and a ``hi`` value, specifying the bounds along
that dimension. To make things confusing, each dimension also has ``min``
and ``max``
constraint
s, which define the minimum/maximum values that the
and ``max``
attribute
s, which define the minimum/maximum values that the
``lo`` and ``high`` values may take for that dimension.
Some dynamic attributes are available on ``BoundsValueList`` objects,
allowing access to and assignment of bound values and
constraint
s. Dimensions ``0, 1, 2, 3`` respectively map to identifiers
attribute
s. Dimensions ``0, 1, 2, 3`` respectively map to identifiers
``x, y, z, t``. If an attempt is made to access/assign an attribute
corresponding to a dimension which does not exist on a particular
``BoundsValueList`` instance (e.g. attribute ``t`` on a 3-dimensional
...
...
@@ -1200,7 +1200,7 @@ class Bounds(List):
and :meth:`BoundsValueList.setMax` methods. The advantage to using these
methods, instead of using, for example,
:meth:`.PropertyValue.setAttribute`, is that if you use the latter you will
have to set the
constraint
s on both the low and the high values.
have to set the
attribute
s on both the low and the high values.
"""
def
__init__
(
self
,
...
...
@@ -1212,7 +1212,7 @@ class Bounds(List):
"""Create a ``Bounds`` property.
:arg ndims: Number of dimensions. This is (currently)
not a property
constraint
, hence it cannot
not a property
attribute
, hence it cannot
be changed.
:arg real: If ``True`` (the default), the bound values are
...
...
@@ -1266,7 +1266,7 @@ class Bounds(List):
methods/attributes defined in the BVL class.
"""
default
=
self
.
_defaultConstraints
.
get
(
'default'
,
None
)
default
=
self
.
getAttribute
(
None
,
'default'
,
None
)
bvl
=
BoundsValueList
(
instance
,
...
...
@@ -1276,8 +1276,8 @@ class Bounds(List):
itemEqualityFunc
=
self
.
_listType
.
_equalityFunc
,
itemValidateFunc
=
self
.
_listType
.
validate
,
listValidateFunc
=
self
.
validate
,
listAttributes
=
self
.
_default
Constraint
s
,
itemAttributes
=
self
.
_listType
.
_default
Constraint
s
)
listAttributes
=
self
.
_default
Attribute
s
,
itemAttributes
=
self
.
_listType
.
_default
Attribute
s
)
return
bvl
...
...
@@ -1499,7 +1499,7 @@ class Point(List):
methods/attributes defined in the PVL class.
"""
default
=
self
.
_defaultConstraints
.
get
(
'default'
,
None
)
default
=
self
.
getAttribute
(
None
,
'default'
,
None
)
pvl
=
PointValueList
(
instance
,
...
...
@@ -1509,8 +1509,8 @@ class Point(List):
itemEqualityFunc
=
self
.
_listType
.
_equalityFunc
,
itemValidateFunc
=
self
.
_listType
.
validate
,
listValidateFunc
=
self
.
validate
,
listAttributes
=
self
.
_default
Constraint
s
,
itemAttributes
=
self
.
_listType
.
_default
Constraint
s
)
listAttributes
=
self
.
_default
Attribute
s
,
itemAttributes
=
self
.
_listType
.
_default
Attribute
s
)
return
pvl
...
...
@@ -1638,7 +1638,7 @@ class Array(props.PropertyBase):
an :class:`.ArrayProxy` for the given ``instance``.
"""
default
=
self
.
_defaultConstraints
.
get
(
'default'
,
None
)
default
=
self
.
getAttribute
(
None
,
'default'
,
None
)
ap
=
ArrayProxy
(
instance
,
name
=
self
.
getLabel
(
instance
),
...
...
@@ -1646,7 +1646,7 @@ class Array(props.PropertyBase):
castFunc
=
self
.
cast
,
validateFunc
=
self
.
validate
,
allowInvalid
=
self
.
_allowInvalid
,
**
self
.
_default
Constraint
s
)
**
self
.
_default
Attribute
s
)
return
ap
...
...
fsleyes_props/properties_value.py
View file @
3ac5dadc
...
...
@@ -177,7 +177,7 @@ class PropertyValue(object):
classes, however they are used by the
:class:`.PropertyBase` and
:class:`.ListPropertyBase` classes to store
per-instance property
constraint
s. Listeners
per-instance property
attribute
s. Listeners
may register to be notified when attribute
values change.
"""
...
...
fsleyes_props/widgets.py
View file @
3ac5dadc
...
...
@@ -416,8 +416,8 @@ def _FilePath(parent, hasProps, propObj, propVal, **kwargs):
panel
.
SetAutoLayout
(
1
)
sizer
.
Fit
(
panel
)
exists
=
propObj
.
get
Constraint
(
hasProps
,
'exists'
)
isFile
=
propObj
.
get
Constraint
(
hasProps
,
'isFile'
)
exists
=
propObj
.
get
Attribute
(
hasProps
,
'exists'
)
isFile
=
propObj
.
get
Attribute
(
hasProps
,
'isFile'
)
def
_choosePath
(
ev
):
global
_lastFilePathDir
...
...
fsleyes_props/widgets_bounds.py
View file @
3ac5dadc
...
...
@@ -70,7 +70,7 @@ def _Bounds(parent,
ndims
=
propObj
.
_ndims
real
=
propObj
.
_real
clamped
=
propObj
.
getListType
().
get
Constraint
(
None
,
'clamped'
)
clamped
=
propObj
.
getListType
().
get
Attribute
(
None
,
'clamped'
)
panel
=
wx
.
Panel
(
parent
)
sizer
=
wx
.
BoxSizer
(
wx
.
VERTICAL
)
...
...
@@ -80,7 +80,7 @@ def _Bounds(parent,
labels
=
[
None
]
*
2
*
ndims
for
i
in
range
(
ndims
):
minDistance
=
propObj
.
get
Constraint
(
hasProps
,
'minDistance'
)
minDistance
=
propObj
.
get
Attribute
(
hasProps
,
'minDistance'
)
minval
=
propVal
.
getMin
(
i
)
maxval
=
propVal
.
getMax
(
i
)
loval
=
propVal
.
getLo
(
i
)
...
...
fsleyes_props/widgets_list.py
View file @
3ac5dadc
...
...
@@ -96,8 +96,8 @@ def _editListDialog(parent, hasProps, propObj):
# min/max values for a spin box which allows the
# user to select the number of items in the list
minval
=
propObj
.
get
Constraint
(
hasProps
,
'minlen'
)
maxval
=
propObj
.
get
Constraint
(
hasProps
,
'maxlen'
)
minval
=
propObj
.
get
Attribute
(
hasProps
,
'minlen'
)
maxval
=
propObj
.
get
Attribute
(
hasProps
,
'maxlen'
)
if
minval
is
None
:
minval
=
0
if
maxval
is
None
:
maxval
=
2
**
31
-
1
...
...
@@ -154,7 +154,7 @@ def _editListDialog(parent, hasProps, propObj):
newLen
=
numRowsCtrl
.
GetValue
()
# add rows
default
=
listType
.
get
Constraint
(
hasProps
,
'default'
)
default
=
listType
.
get
Attribute
(
hasProps
,
'default'
)
while
oldLen
<
newLen
:
# add a new element to the list
...
...
fsleyes_props/widgets_number.py
View file @
3ac5dadc
...
...
@@ -256,7 +256,7 @@ def _makeSlider(parent,
widgets
.
_propBind
(
hasProps
,
propObj
,
propVal
,
slider
,
evt
)
# Update slider min/max bounds and labels
# whenever the property
constraint
s change.
# whenever the property
attribute
s change.
def
updateSliderRange
(
*
a
):
minval
=
propVal
.
getAttribute
(
'minval'
)
maxval
=
propVal
.
getAttribute
(
'maxval'
)
...
...
@@ -284,7 +284,7 @@ def _makeSlider(parent,
if
editLimits
:
# When the user edits the slider bounds,
# update the property
constraint
s
# update the property
attribute
s
def
updatePropRange
(
ev
):
propVal
.
setAttribute
(
'minval'
,
ev
.
min
)
propVal
.
setAttribute
(
'maxval'
,
ev
.
max
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment