Getting properties

Some new properties are introduced to the ScientificSpinBox which aren’t present on DoubleSpinBox. They are:

  • quantity

  • backend

  • baseValue

  • baseUnit

  • baseQuantity

quantity

Type: any quantity object created from the BackendInterface implementation that operates as a quantity

This property holds the current quantity being displayed on the spinbox. It returns a Quantity object generated from the specific BackendInterface being used by the widget.

In the case of using the PintInterface, it will return a pint.UnitRegistry.Quantity object, with the current float value and units being displayed on the widget.

Attention: Do not mistake quantity with baseQuantity: the baseQuantity object returns the current numeric and unit parts of the quantity in terms of the defined base unit.

Let’s consider an example to clarify this:

  • If the current quantity being displayed is 0.005 s, then quantity will return a quantity with 0.005 s, exactly equal to the one being displayed.

  • If the current quantity being displayed is 0.005 s and the baseUnit is defined as ms, then baseQuantity will return a quantity with 5 ms, converting seconds to miliseconds.

backend

Type: BackendInterface

This property holds the specific BackendInterface object which the widget is using for unit handling.

All BackendInterface inherited classes must implement specific methods that enables the widget to correctly represent, operate and manipulate quantities in a well defined way.

baseValue

Type: float

This property holds the current float value of the widget in terms of the baseQuantity unit.

For example, if the widget’s quantity float value is 3.0005 and the quantity unit part is m (meters), let the baseQuantity be in ms, then baseValue will be a float 3000.05 value, which is exactly the float value of 3.0005 m converted to ms.

In a more concise way, baseValue returns the float part of baseQuantity.

baseUnit

Type: str

This property holds the unit part of baseQuantity, that is, the unit in which the baseValue is converted to.

baseQuantity

Type: any quantity object created from the BackendInterface implementation that operates as a quantity

This property holds the quantity that represents the current value and unit of the spinbox in terms of the base unit.

That is, let baseUnit be ms. If quantity represents 0.05 m, then baseQuantity represents 50 ms.

Attention: Do not mistake quantity with baseQuantity: the baseQuantity object returns the current numeric and unit parts of the quantity in terms of the defined base unit.

Let’s consider an example to clarify this:

  • If the current quantity being displayed is 0.005 s, then quantity will return a quantity with 0.005 s, exactly equal to the one being displayed.

  • If the current quantity being displayed is 0.005 s and the baseUnit is defined as ms, then baseQuantity will return a quantity with 5 ms, converting seconds to miliseconds.