Attribute (hwx.inspire.Attributes)#

class Attribute(fget=None, fset=None, doc=None, default=None, **kwds)#

Bases: property

Python descriptor to set or get serializable values of Inspire objects.

Base class for all the attributes.

Attribute Table#

Name

Type

Value

NoneType

attr

NoneType

baseUnits

Units

category

str

computed

bool

default

NoneType

incore

bool

listCls

NoneType

listListCls

NoneType

name

NoneType

readonly

bool

units

str

Method Table#

Name

Description

apply (**kwds)

Context manager to specify Attribute constructor kwds

castForGet (self, obj, value)

Converts and returns the attribute value to its external type.

castForSet (self, obj, value)

Converts and validates the value of the attribute before setting.

classifyObject (self, obj)

create (self, obj)

Creates a attribute for the specified object.

createList (self, listAttr, obj)

Creates an attribute that has list of values for the specified object.

createListList (self, listAttr, obj)

Creates an attribute that has nested list of values for the specified object.

disable (self, obj)

Disables the attribute.

enable (self, obj)

Enables the attribute.

getCreateArgs (self)

Helper used in create methods

getDisplayName (self, obj)

getGuiValue (self, obj)

Returns the formatted value, as shown in the Property Editor.

getInCoreValue (self, obj)

Calls the incore get method (defined in C++) of the attribute.

getReadonly (self, obj)

getUnits (self, obj)

getValue (self, obj)

Returns the attribute value of the specified object.

getValueList (self, obj)

Returns the list of values from the specified object.

getValueListList (self, obj)

Returns the nested list of values from the specified object.

initialize (self, objCls, name)

Initializes the attribute.

loadValue (self, obj, value)

Loads and sets the value, when a model is loaded.

populateGuiValue (self, obj, prop)

Override to customize, prop.value, displayValue, allowedValues.

populatePropertyEditor (self, obj, prop, **kwds)

Customize how attribute appears in Property Editor and ObjectTables.

setInCoreValue (self, obj, value)

Calls the incore set method (defined in C++) of the attribute.

setValue (self, obj, value)

Sets the value for the specified object attribute.

setValueList (self, obj, value)

Sets the specified list of values for the attribute.

setValueListList (self, obj, value)

Sets the specified nested list of values for the attribute.

usingUnits (self, units)

initialize(objCls, name)#

Initializes the attribute.

Parameters:
  • objCls (class) – Object class this attribute belongs to.

  • name (str) – Name of the attribute.

getCreateArgs()#

Helper used in create methods

create(obj)#

Creates a attribute for the specified object.

Overridden by the child class create method.

castForSet(obj, value)#

Converts and validates the value of the attribute before setting.

Converts the value it to its internal type (and base units if applicable).

Parameters:
  • obj (GeneralObject) – Object this attribute belongs to.

  • value (Any) – Value of the attribute to set.

Returns:

Validated and converted value.

Return type:

value (Any)

castForGet(obj, value)#

Converts and returns the attribute value to its external type.

Parameters:
  • obj (GeneralObject) – Object this attribute belongs to.

  • value (Any) – Value of the attribute to be converted.

Returns:

Converted value.

Return type:

value (Any)

setInCoreValue(obj, value)#

Calls the incore set method (defined in C++) of the attribute.

Parameters:
  • obj (GeneralObject) – Object this attribute belongs to.

  • value (Any) – Value of the attribute to set.

getInCoreValue(obj)#

Calls the incore get method (defined in C++) of the attribute.

Parameters:
  • obj (GeneralObject) – Object this attribute belongs to.

  • value (Any) – Value of the attribute to get.

Returns:

Value returned by the incore get method.

Return type:

Any

populatePropertyEditor(obj, prop, **kwds)#

Customize how attribute appears in Property Editor and ObjectTables.

Parameters:
  • obj (GeneralObject) –

  • prop (hwt::Property) – Property Editor interface.

  • component (int) – 0, 1, 2 Only passed when showing Triples 1 value at a time.

populateGuiValue(obj, prop)#

Override to customize, prop.value, displayValue, allowedValues.

The prop.value type determines which editor widget used: - bool -> checkbox - str -> line edit - hwtypes.Color -> color picker

Setting prop.allowedValues yields a ComboBox.

prop.displayValue is a str shown when the editor loses focus.

getValue(obj)#

Returns the attribute value of the specified object.

setValue(obj, value)#

Sets the value for the specified object attribute.

loadValue(obj, value)#

Loads and sets the value, when a model is loaded.

getGuiValue(obj)#

Returns the formatted value, as shown in the Property Editor.

enable(obj)#

Enables the attribute.

disable(obj)#

Disables the attribute.

createList(listAttr, obj)#

Creates an attribute that has list of values for the specified object.

getValueList(obj)#

Returns the list of values from the specified object.

setValueList(obj, value)#

Sets the specified list of values for the attribute.

createListList(listAttr, obj)#

Creates an attribute that has nested list of values for the specified object.

getValueListList(obj)#

Returns the nested list of values from the specified object.

setValueListList(obj, value)#

Sets the specified nested list of values for the attribute.