Class UnitT
- protocol ooodev.units.unit_obj.UnitT[source]
Protocol Class for units.
See also
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
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind) – The kind of
AppFontto use.
- Return type:
Note
AppFont units have different values when converted. This is true even if they have the same value in
AppFontunits.AppFontX(10)is not equal toAppFontY(10)when they are converted to different units.Kindwhenintis used, the value must be one of the following:0isPointSizeKind.X,1isPointSizeKind.Y,2isPointSizeKind.WIDTH,3isPointSizeKind.HEIGHT.
Hint
PointSizeKindcan be imported fromooodev.utils.kind.point_size_kind.
- classmethod from_unit_val(value)[source]
Get instance from
UnitTor float or int value.- Parameters:
value (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be in1/100th mmunits.- 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:
New in version 0.34.1.
- get_value_app_font(kind)[source]
Gets instance value in
AppFontunits.- Returns:
Value in
AppFontunits. kind (PointSizeKind, optional): The kind ofAppFontto 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
AppFontunits.AppFontX(10)is not equal toAppFontY(10)when they are converted to different units.Kindwhenintis used, the value must be one of the following:0isPointSizeKind.X,1isPointSizeKind.Y,2isPointSizeKind.WIDTH,3isPointSizeKind.HEIGHT.
Hint
PointSizeKindcan be imported fromooodev.utils.kind.point_size_kind.
- get_value_mm()[source]
Gets instance value converted to Size in
mmunits.- Returns:
Value in
mmunits.- Return type:
float
- get_value_mm100()[source]
Gets instance value converted to Size in
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to Size in
pt(point) units.- Returns:
Value in
ptunits.- Return type:
float
- get_value_px()[source]
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- 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
floatorint- Return type:
Union[float,int]