Class UnitT

protocol ooodev.units.unit_obj.UnitT[source]

Protocol Class for units.

See also

units

Classes that implement this protocol must have the following methods / attributes:

__init__(*args, **kwargs)
__int__()[source]

Gets instance value as an integer.

Returns:

Value as an integer.

Return type:

int

convert_to(unit)[source]

Converts instance value to specified unit.

Parameters:

unit (UnitLength) – Unit to convert to.

Returns:

Value in specified unit.

Return type:

float

New in version 0.34.1.

classmethod from_app_font(value, kind)[source]

Get instance from AppFont value.

Parameters:
  • value (int) – AppFont value.

  • kind (PointSizeKind) – The kind of AppFont to use.

Return type:

UnitPX

Note

AppFont units have different values when converted. This is true even if they have the same value in AppFont units. AppFontX(10) is not equal to AppFontY(10) when they are converted to different units.

Kind when int is used, the value must be one of the following:

  • 0 is PointSizeKind.X,

  • 1 is PointSizeKind.Y,

  • 2 is PointSizeKind.WIDTH,

  • 3 is PointSizeKind.HEIGHT.

Hint

  • PointSizeKind can be imported from ooodev.utils.kind.point_size_kind.

classmethod from_unit_val(value)[source]

Get instance from UnitT or float or int value.

Parameters:

value (UnitT, float, int) – UnitT or float value. If float then it is assumed to be in 1/100th mm units.

Returns:

Instance.

Return type:

Self

New in version 0.34.1.

static get_unit_length()[source]

Gets instance unit length.

Returns:

Instance unit length UnitLength.PX.

Return type:

UnitLength

New in version 0.34.1.

get_value_app_font(kind)[source]

Gets instance value in AppFont units.

Returns:

Value in AppFont units. kind (PointSizeKind, optional): The kind of AppFont to use.

Return type:

float

Parameters:

kind (PointSizeKind | int) –

Note

AppFont units have different values when converted. This is true even if they have the same value in AppFont units. AppFontX(10) is not equal to AppFontY(10) when they are converted to different units.

Kind when int is used, the value must be one of the following:

  • 0 is PointSizeKind.X,

  • 1 is PointSizeKind.Y,

  • 2 is PointSizeKind.WIDTH,

  • 3 is PointSizeKind.HEIGHT.

Hint

  • PointSizeKind can be imported from ooodev.utils.kind.point_size_kind.

get_value_mm()[source]

Gets instance value converted to Size in mm units.

Returns:

Value in mm units.

Return type:

float

get_value_mm100()[source]

Gets instance value converted to Size in 1/100th mm units.

Returns:

Value in 1/100th mm units.

Return type:

int

get_value_pt()[source]

Gets instance value converted to Size in pt (point) units.

Returns:

Value in pt units.

Return type:

float

get_value_px()[source]

Gets instance value in px (pixel) units.

Returns:

Value in px units.

Return type:

float

__protocol_attrs__ = {'__int__', 'convert_to', 'from_app_font', 'from_unit_val', 'get_unit_length', 'get_value_app_font', 'get_value_mm', 'get_value_mm100', 'get_value_pt', 'get_value_px', 'value'}
property value: float | int

Unit actual value. Generally a float or int

Return type:

Union[float, int]