units
New in version 0.9.0.
Contents
- class ooodev.units.Angle(value)[source]
Represents an angle value from
0to359.All input integers are converted into a positive angle.
Example
>>> print(Angle(360)) Angle(Value=0) >>> print(Angle(413)) Angle(Value=53) >>> print(Angle(-235)) Angle(Value=125) >>> print(Angle(1794)) Angle(Value=354)
Changed in version 0.8.1: Now will accept any integer value, negative or positive.
- Parameters:
value (int) –
- __init__(value)
- Parameters:
value (int) –
- Return type:
None
- static from_angle(value)[source]
Get an angle from
degreeunits.- Parameters:
value (int) – Angle in
degreeunits.- Return type:
- static from_angle10(value)[source]
Get an angle from
1/10 degreeunits.- Parameters:
value (int) – Angle in
1/10 degreeunits.- Return type:
- static from_angle100(value)[source]
Get an angle from
1/100 degreeunits.- Parameters:
value (int) – Angle in
1/10 degreeunits.- Return type:
- classmethod from_unit_val(value)[source]
Get instance from
Angleor int value.- Parameters:
value (Angle, int) –
Angleor int value. If int then it is assumed to be in degrees.- Return type:
New in version 0.32.0.
- value: int
Int value.
- class ooodev.units.Angle10(value)[source]
Represents an angle value from
0to3599.All input integers are converted into a positive angle.
Example
>>> print(Angle10(3600)) Angle10(Value=0) >>> print(Angle10(4130)) Angle10(Value=530) >>> print(Angle10(-2350)) Angle10(Value=1250) >>> print(Angle10(17940)) Angle10(Value=3540)
New in version 0.17.4.
- Parameters:
value (int) –
- __init__(value)
- Parameters:
value (int) –
- Return type:
None
- static from_angle(value)[source]
Get an angle from
degreeunits.- Parameters:
value (int) – Angle10 in
degreeunits.- Return type:
- static from_angle10(value)[source]
Get an angle from
1/10 degreeunits.- Parameters:
value (int) – Angle10 in
1/10 degreeunits.- Return type:
- static from_angle100(value)[source]
Get an angle from
1/100 degreeunits.- Parameters:
value (int) – Angle10 in
1/10 degreeunits.- Return type:
- classmethod from_unit_val(value)[source]
Get instance from
Angle10or int value.- Parameters:
value (Angle10, int) –
Angle10or int value. If int then it is assumed to be in1/10thdegrees.- Return type:
New in version 0.32.0.
- value: int
Int value.
- class ooodev.units.Angle100(value)[source]
Represents an angle value from
0to35999in1/100 units.All input integers are converted into a positive angle.
Example
>>> print(Angle100(36000)) Angle100(Value=0) >>> print(Angle(41300)) Angle100(Value=5300) >>> print(Angle(-23500)) Angle(Value=12500) >>> Angle100(Angle(179400)) Angle(Value=35400)
New in version 0.17.4.
- Parameters:
value (int) –
- __init__(value)
- Parameters:
value (int) –
- Return type:
None
- static from_angle(value)[source]
Get an angle from
degreeunits.- Parameters:
value (int) – Angle in
degreeunits.- Return type:
- static from_angle10(value)[source]
Get an angle from
1/10 degreeunits.- Parameters:
value (int) – Angle in
1/10 degreeunits.- Return type:
- static from_angle100(value)[source]
Get an angle from
1/100 degreeunits.- Parameters:
value (int) – Angle in
1/100 degreeunits.- Return type:
- classmethod from_unit_val(value)[source]
Get instance from
Angle100or int value.- Parameters:
value (Angle100, int) –
Angle100or int value. If int then it is assumed to be in1/100thdegrees.- Return type:
New in version 0.32.0.
- value: int
Int value.
- class ooodev.units.AngleUnitT[source]
Protocol Class for Angle units.
See also
- __init__()
- property value: float | int
Angle actual value. Generally a
floatorint- Return type:
float | int
- class ooodev.units.AppFontPos(x, y)[source]
A class to represent the application font position.
This class is a container for the
XandYapplication font position units.Note
The
XandYunits are based on the application font position ratio. This means that theXandYunits may not not be based on the same unit length.- Parameters:
x (UnitAppFontX) –
y (UnitAppFontY) –
- __init__(x, y)[source]
Constructor
- Parameters:
x (UnitAppFontX) – The X value of the application font position.
y (UnitAppFontY) – The Y value of the application font position.
- Return type:
None
- classmethod from_app_font(x, y)[source]
Creates an instance from
1/100th mmvalues.- Parameters:
x (float) – The X value of the application font position.
y (float) – The Y value of the application font position.
- Returns:
An instance of AppFontPos.
- Return type:
- property x: UnitAppFontX
Gets/Sets the
Xunit of the application font position.When setting can be a float or a
UnitT.- Return type:
- property y: UnitAppFontY
Get/Sets the
Yunit of the application font position.When setting can be a float or a
UnitT.- Return type:
- class ooodev.units.AppFontSize(width, height)[source]
A class to represent the application font size.
This class is a container for the
WidthandHeightapplication font size units.Note
The
WidthandHeightunits are based on the application font size ratio. This means that theWidthandHeightunits may not be based on the same unit length.- Parameters:
width (UnitAppFontWidth) –
height (UnitAppFontHeight) –
- __init__(width, height)[source]
Constructor
- Parameters:
width (UnitAppFontWidth) – The
Widthvalue of the application font size.height (UnitAppFontHeight) – The
Heightvalue of the application font size.
- Return type:
None
- classmethod from_app_font(x, y)[source]
Creates an instance from
1/100th mmvalues.- Parameters:
x (float) – The
Widthvalue of the application font size.y (float) – The
Heightvalue of the application font size.
- Returns:
An instance of SizeMM100.
- Return type:
- property height: UnitAppFontHeight
Get/Sets the
Heightunit of the application font size.When setting can be a float or a
UnitT.- Return type:
- property width: UnitAppFontWidth
Gets/Sets the
Width``unit of the application font size.When setting can be a float or a
UnitT.- Return type:
- class ooodev.units.SizeMM100(width, height)[source]
Size Width and Height in
1/100th mmunits.New in version 0.27.0.
- convert_to(unit_length)
Converts current values to specified unit length.
- Parameters:
unit_length (UnitLength) – Unit length to convert to.
- Returns:
Converted Units.
- Return type:
GenericUnitSize[UnitT, Union[int, float]]
- classmethod from_mm100(width, height)[source]
Creates an instance from
1/100th mmvalues.- Parameters:
width (int) – Width value as
1/100th mm.height (int) – Height value as
1/100th mm.
- Returns:
An instance of SizeMM100.
- Return type:
- get_size()
Gets instance value as Size
- Return type:
GenericSize[TypeVar(TNum, bound=Union[int,float])]
- class ooodev.units.SizePX(width, height)[source]
Size Width and Height in
pxunits.New in version 0.27.0.
- convert_to(unit_length)
Converts current values to specified unit length.
- Parameters:
unit_length (UnitLength) – Unit length to convert to.
- Returns:
Converted Units.
- Return type:
GenericUnitSize[UnitT, Union[int, float]]
- classmethod from_px(width, height)[source]
Creates an instance from
pxvalues.- Parameters:
width (float) – Width value as
px.height (float) – Height value as
px.
- Returns:
An instance of SizePX.
- Return type:
- get_size()
Gets instance value as Size
- Return type:
GenericSize[TypeVar(TNum, bound=Union[int,float])]
- class ooodev.units.SizePosMM100(x, y, width, height)[source]
Size and Position in
1/100 mmunits.New in version 0.39.0.
- convert_to(unit_length)
Converts current values to specified unit length.
- Parameters:
unit_length (UnitLength) – Unit length to convert to.
- Returns:
Converted Units.
- Return type:
GenericUnitSize[UnitT, Union[int, float]]
- classmethod from_unit_val(x, y, width, height)[source]
Get instance from
UnitTor float value.- Parameters:
x (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be in1/100 mmunits.y (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be in1/100 mmunits.width (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be in1/100 mmunits.height (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be in1/100 mmunits.
- Return type:
- get_size_pos()
Gets instance value as Size
- Return type:
GenericSizePos[TypeVar(TNum, bound=Union[int,float])]
- get_uno_point_size()
Gets current values as Point and Size
- get_uno_rectangle()
Gets current values as Rectangle
- Returns:
UNO Rectangle.
- Return type:
Rectangle
- class ooodev.units.SizePosPX(x, y, width, height)[source]
Size and Position in
pxunits.New in version 0.39.0.
- convert_to(unit_length)
Converts current values to specified unit length.
- Parameters:
unit_length (UnitLength) – Unit length to convert to.
- Returns:
Converted Units.
- Return type:
GenericUnitSize[UnitT, Union[int, float]]
- classmethod from_unit_val(x, y, width, height)[source]
Get instance from
UnitTor float value.- Parameters:
x (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be inpxunits.y (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be inpxunits.width (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be inpxunits.height (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be inpxunits.
- Return type:
- get_size_pos()
Gets instance value as Size
- Return type:
GenericSizePos[TypeVar(TNum, bound=Union[int,float])]
- get_uno_point_size()
Gets current values as Point and Size
- get_uno_rectangle()
Gets current values as Rectangle
- Returns:
UNO Rectangle.
- Return type:
Rectangle
- class ooodev.units.UnitAppFontHeight(value)[source]
Unit in
AppFontunits.Supports
UnitTprotocol.Warning
Although this class support
UnitTprotocol,get_unit_length()method returnsUnitLength.INVALID.Note
Unlike most other units in this module, this unit is not based on
UnitLength. This means that it does not have a validUnitLengthvalue and returnsUnitLength.INVALID.This unit require that the application font pixel ratio be set before it can be used. Which means office must be loaded before this unit can be used.
See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- convert_to(unit)
Converts instance value to specified unit.
- Parameters:
unit (UnitLength) – Unit to convert to.
- Returns:
Value in specified unit.
- Return type:
float
Hint
UnitLengthcan be imported fromooodev.units.
- classmethod from_app_font(value, kind=None)
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – The kind of
AppFontto use. This is not used in the context ofAppFontunits.
- Return type:
Self
- classmethod from_cm(value)
Get instance from
cmvalue.- Parameters:
value (int) –
cmvalue.- Return type:
Self
- classmethod from_inch(value)
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
Self
- classmethod from_inch10(value)
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
Self
- classmethod from_inch100(value)
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
Self
- classmethod from_inch1000(value)
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
Self
- classmethod from_mm(value)
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
Self
- classmethod from_mm10(value)
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
Self
- classmethod from_mm100(value)
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
Self
- classmethod from_pt(value)
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
Self
- classmethod from_px(value)
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
Self
- classmethod from_unit_val(value)
Get instance from
UnitTor float value.- Parameters:
value (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be inmmunits.- Return type:
Self
- get_app_font_kind()[source]
Gets the kind of the unit.
- Returns:
Returns
PointSizeKind.HEIGHT- Return type:
- static get_unit_length()
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.INVALID.- Return type:
- get_value_app_font(kind=None)
Gets instance value in
AppFontunits.- Returns:
Value in
AppFontunits. kind (Any): Ignored in the context ofAppFontunits. It is used in other units.- Return type:
float
- Parameters:
kind (Any | None) –
- get_value_cm()
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
float
- get_value_inch()
Gets instance value in
in(inch) units.- Returns:
Value in
inunits.- Return type:
float
- get_value_inch10()
Gets instance value in
1/10th inchunits.- Returns:
Value in
1/10th inchunits.- Return type:
int
- get_value_inch100()
Gets instance value in
1/100th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_inch1000()
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_mm()
Gets instance value converted to Size in
mmunits.- Returns:
Value in
mmunits.- Return type:
float
- get_value_mm100()
Gets instance value converted to Size in
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_oth_unit()[source]
Return the Y value of the unit.
- Returns:
The Y value of the unit. This is the value of a
UnitAppFontYunit.- Return type:
float
- get_value_pt()
Gets instance value converted to Size in
pt(points) units.- Returns:
Value in
ptunits.- Return type:
float
- get_value_px()
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
float
- value: float
Float value.
- class ooodev.units.UnitAppFontWidth(value)[source]
Unit in
AppFontunits.Supports
UnitTprotocol.Warning
Although this class support
UnitTprotocol,get_unit_length()method returnsUnitLength.INVALID.Note
Unlike most other units in this module, this unit is not based on
UnitLength. This means that it does not have a validUnitLengthvalue and returnsUnitLength.INVALID.This unit require that the application font pixel ratio be set before it can be used. Which means office must be loaded before this unit can be used.
See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- convert_to(unit)
Converts instance value to specified unit.
- Parameters:
unit (UnitLength) – Unit to convert to.
- Returns:
Value in specified unit.
- Return type:
float
Hint
UnitLengthcan be imported fromooodev.units.
- classmethod from_app_font(value, kind=None)
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – The kind of
AppFontto use. This is not used in the context ofAppFontunits.
- Return type:
Self
- classmethod from_cm(value)
Get instance from
cmvalue.- Parameters:
value (int) –
cmvalue.- Return type:
Self
- classmethod from_inch(value)
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
Self
- classmethod from_inch10(value)
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
Self
- classmethod from_inch100(value)
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
Self
- classmethod from_inch1000(value)
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
Self
- classmethod from_mm(value)
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
Self
- classmethod from_mm10(value)
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
Self
- classmethod from_mm100(value)
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
Self
- classmethod from_pt(value)
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
Self
- classmethod from_px(value)
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
Self
- classmethod from_unit_val(value)
Get instance from
UnitTor float value.- Parameters:
value (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be inmmunits.- Return type:
Self
- get_app_font_kind()[source]
Gets the kind of the unit.
- Returns:
Returns
PointSizeKind.WIDTH- Return type:
- static get_unit_length()
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.INVALID.- Return type:
- get_value_app_font(kind=None)
Gets instance value in
AppFontunits.- Returns:
Value in
AppFontunits. kind (Any): Ignored in the context ofAppFontunits. It is used in other units.- Return type:
float
- Parameters:
kind (Any | None) –
- get_value_cm()
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
float
- get_value_inch()
Gets instance value in
in(inch) units.- Returns:
Value in
inunits.- Return type:
float
- get_value_inch10()
Gets instance value in
1/10th inchunits.- Returns:
Value in
1/10th inchunits.- Return type:
int
- get_value_inch100()
Gets instance value in
1/100th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_inch1000()
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_mm()
Gets instance value converted to Size in
mmunits.- Returns:
Value in
mmunits.- Return type:
float
- get_value_mm100()
Gets instance value converted to Size in
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_oth_unit()[source]
Return the Y value of the unit.
- Returns:
The Y value of the unit. This is the value of a
UnitAppFontYunit.- Return type:
float
- get_value_pt()
Gets instance value converted to Size in
pt(points) units.- Returns:
Value in
ptunits.- Return type:
float
- get_value_px()
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
float
- value: float
Float value.
- class ooodev.units.UnitAppFontX(value)[source]
Unit in
AppFontunits.Supports
UnitTprotocol.Warning
Although this class support
UnitTprotocol,get_unit_length()method returnsUnitLength.INVALID.Note
Unlike most other units in this module, this unit is not based on
UnitLength. This means that it does not have a validUnitLengthvalue and returnsUnitLength.INVALID.This unit require that the application font pixel ratio be set before it can be used. Which means office must be loaded before this unit can be used.
See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- convert_to(unit)
Converts instance value to specified unit.
- Parameters:
unit (UnitLength) – Unit to convert to.
- Returns:
Value in specified unit.
- Return type:
float
Hint
UnitLengthcan be imported fromooodev.units.
- classmethod from_app_font(value, kind=None)
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – The kind of
AppFontto use. This is not used in the context ofAppFontunits.
- Return type:
Self
- classmethod from_cm(value)
Get instance from
cmvalue.- Parameters:
value (int) –
cmvalue.- Return type:
Self
- classmethod from_inch(value)
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
Self
- classmethod from_inch10(value)
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
Self
- classmethod from_inch100(value)
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
Self
- classmethod from_inch1000(value)
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
Self
- classmethod from_mm(value)
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
Self
- classmethod from_mm10(value)
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
Self
- classmethod from_mm100(value)
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
Self
- classmethod from_pt(value)
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
Self
- classmethod from_px(value)
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
Self
- classmethod from_unit_val(value)
Get instance from
UnitTor float value.- Parameters:
value (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be inmmunits.- Return type:
Self
- get_app_font_kind()[source]
Gets the kind of the unit.
- Returns:
Returns
PointSizeKind.X- Return type:
- static get_unit_length()
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.INVALID.- Return type:
- get_value_app_font(kind=None)
Gets instance value in
AppFontunits.- Returns:
Value in
AppFontunits. kind (Any): Ignored in the context ofAppFontunits. It is used in other units.- Return type:
float
- Parameters:
kind (Any | None) –
- get_value_cm()
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
float
- get_value_inch()
Gets instance value in
in(inch) units.- Returns:
Value in
inunits.- Return type:
float
- get_value_inch10()
Gets instance value in
1/10th inchunits.- Returns:
Value in
1/10th inchunits.- Return type:
int
- get_value_inch100()
Gets instance value in
1/100th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_inch1000()
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_mm()
Gets instance value converted to Size in
mmunits.- Returns:
Value in
mmunits.- Return type:
float
- get_value_mm100()
Gets instance value converted to Size in
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_oth_unit()[source]
Return the Y value of the unit.
- Returns:
The Y value of the unit. This is the value of a
UnitAppFontYunit.- Return type:
float
- get_value_pt()
Gets instance value converted to Size in
pt(points) units.- Returns:
Value in
ptunits.- Return type:
float
- get_value_px()
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
float
- value: float
Float value.
- class ooodev.units.UnitAppFontY(value)[source]
Unit in
AppFontunits.Supports
UnitTprotocol.Warning
Although this class support
UnitTprotocol,get_unit_length()method returnsUnitLength.INVALID.Note
Unlike most other units in this module, this unit is not based on
UnitLength. This means that it does not have a validUnitLengthvalue and returnsUnitLength.INVALID.This unit require that the application font pixel ratio be set before it can be used. Which means office must be loaded before this unit can be used.
See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- convert_to(unit)
Converts instance value to specified unit.
- Parameters:
unit (UnitLength) – Unit to convert to.
- Returns:
Value in specified unit.
- Return type:
float
Hint
UnitLengthcan be imported fromooodev.units.
- classmethod from_app_font(value, kind=None)
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – The kind of
AppFontto use. This is not used in the context ofAppFontunits.
- Return type:
Self
- classmethod from_cm(value)
Get instance from
cmvalue.- Parameters:
value (int) –
cmvalue.- Return type:
Self
- classmethod from_inch(value)
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
Self
- classmethod from_inch10(value)
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
Self
- classmethod from_inch100(value)
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
Self
- classmethod from_inch1000(value)
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
Self
- classmethod from_mm(value)
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
Self
- classmethod from_mm10(value)
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
Self
- classmethod from_mm100(value)
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
Self
- classmethod from_pt(value)
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
Self
- classmethod from_px(value)
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
Self
- classmethod from_unit_val(value)
Get instance from
UnitTor float value.- Parameters:
value (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be inmmunits.- Return type:
Self
- get_app_font_kind()[source]
Gets the kind of the unit.
- Returns:
Returns
PointSizeKind.Y- Return type:
- static get_unit_length()
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.INVALID.- Return type:
- get_value_app_font(kind=None)
Gets instance value in
AppFontunits.- Returns:
Value in
AppFontunits. kind (Any): Ignored in the context ofAppFontunits. It is used in other units.- Return type:
float
- Parameters:
kind (Any | None) –
- get_value_cm()
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
float
- get_value_inch()
Gets instance value in
in(inch) units.- Returns:
Value in
inunits.- Return type:
float
- get_value_inch10()
Gets instance value in
1/10th inchunits.- Returns:
Value in
1/10th inchunits.- Return type:
int
- get_value_inch100()
Gets instance value in
1/100th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_inch1000()
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_mm()
Gets instance value converted to Size in
mmunits.- Returns:
Value in
mmunits.- Return type:
float
- get_value_mm100()
Gets instance value converted to Size in
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_oth_unit()[source]
Return the X value of the unit.
- Returns:
The X value of the unit. This is the value of a
UnitAppFontXunit.- Return type:
float
- get_value_pt()
Gets instance value converted to Size in
pt(points) units.- Returns:
Value in
ptunits.- Return type:
float
- get_value_px()
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
float
- value: float
Float value.
- class ooodev.units.UnitCM(value)[source]
Unit in
cmunits.Supports
UnitTprotocol.See also
New in version 0.9.4.
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- 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
- classmethod from_app_font(value, kind)[source]
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – 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_cm(value)[source]
Get instance from
cmvalue.- Parameters:
value (float) –
cmvalue.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
`/10th invalue.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
- classmethod from_px(value)[source]
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
- static get_unit_length()[source]
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.CM.- Return type:
- 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_cm()[source]
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
int
- get_value_inch()[source]
Gets instance value in
in(inch) units.- Returns:
Value in
inunits.- Return type:
float
- get_value_inch10()[source]
Gets instance value in
1/10th inchunits.- Returns:
Value in
1/10th inchunits.- Return type:
int
- get_value_inch100()[source]
Gets instance value in
1/100th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_inch1000()[source]
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mmunits.- Returns:
Value in
mmunits.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to
pt(points) units.- Returns:
Value in
ptunits.- Return type:
int
- get_value_px()[source]
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitConvert[source]
- __init__()
- static asserting_gcd(m, n)[source]
Find the greatest common divisor of the two integers
- Parameters:
m (int) – The first integer to find the GCD for
n (int) – The second integer to find the GCD for
- Raises:
AssertionError – If GCD result equals
0.- Returns:
A value, representing the greatest common divisor (GCD) for two integers
- Return type:
int
- classmethod convert(num: int | float, frm: ooodev.units.unit_convert.UnitLength, to: ooodev.units.unit_convert.UnitLength) float[source]
- classmethod convert(num: int | float, frm: int, to: int) float
- classmethod convert(num, frm, to)
Converts a number from one unit to another unit.
- Parameters:
num (N) – Number to convert such as a
floatorint.frm (int | Length) – Current number kind.
to (int | Length) – Kind to convert to.
- Returns:
Converted number
- Return type:
float
Note
If
Lengthis not used thenmul_div()is called directly.
- classmethod convert_mm100_mm(num)[source]
Converts
mmto1/100th mm- Parameters:
num (N) – Number to convert
- Returns:
Converted number
- Return type:
float
- classmethod convert_mm100_pt(num)[source]
Converts
1/100th mmto points- Parameters:
num (N) – Number to convert
- Returns:
Converted number
- Return type:
float
- classmethod convert_mm_mm100(num)[source]
Converts
1/100th mmtomm- Parameters:
num (N) – Number to convert
- Returns:
Converted number
- Return type:
float
- classmethod convert_pt_mm100(num)[source]
Converts points to
1/100th mm- Parameters:
num (N) – Number to convert
- Returns:
Converted number
- Return type:
float
- classmethod convert_twip_mm100(num)[source]
Converts twips to
1/100th mm- Parameters:
num (N) – Number to convert
- Returns:
Converted number
- Return type:
float
- static make_unsigned(num)[source]
Gets unsigned number
- Parameters:
num (N) – Number
- Raises:
AssertionError – If
numis a negative number.- Returns:
Value of
numif positive number.- Return type:
N
- class ooodev.units.UnitInch(value)[source]
Unit in
inchunits.Supports
UnitTprotocol.See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- 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
- classmethod from_app_font(value, kind)[source]
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – 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_cm(value)[source]
Get instance from
cmvalue.- Parameters:
value (float) –
cmvalue.- Return type:
- classmethod from_inch(value)[source]
Get instance from inch value.
- Parameters:
value (int) – Inch value.
- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mmvalue.- Parameters:
value (float) –
mmvalue.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
- classmethod from_px(value)[source]
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
- static get_unit_length()[source]
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.IN.- Return type:
- 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_cm()[source]
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
int
- get_value_inch()[source]
Gets instance value in inch units.
- Returns:
Value in inch units.
- Return type:
float
- get_value_inch10()[source]
Gets instance value in
1/10th inchunits.- Returns:
Value in
1/10th inchunits.- Return type:
float
- get_value_inch100()[source]
Gets instance value in
1/100th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
float
- get_value_inch1000()[source]
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to Size in
mmunits.- Returns:
Value in
mmunits.- Return type:
int
- 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(points) units.- Returns:
Value in
ptunits.- Return type:
int
- get_value_px()[source]
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitInch10(value)[source]
Unit in
1/10th inunits.Supports
UnitTprotocol.See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- 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
- classmethod from_app_font(value, kind)[source]
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – 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_cm(value)[source]
Get instance from
cmvalue.- Parameters:
value (float) –
cmvalue.- Return type:
- classmethod from_in(value)
Get instance from
in(inch) value.- Parameters:
value (float) –
invalue.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in(inch) value.- Parameters:
value (float) –
invalue.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
- classmethod from_px(value)[source]
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
- classmethod from_unit_val(value)[source]
Get instance from
UnitTor float value.- Parameters:
value (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be ininch10units.- Return type:
- static get_unit_length()[source]
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.IN10.- Return type:
- 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_cm()[source]
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
int
- get_value_inch()[source]
Gets instance value in inch units.
- Returns:
Value in inch units.
- Return type:
float
- get_value_inch10()[source]
Gets instance value in
1/10th inchunits.- Returns:
Value in
1/10th inchunits.- Return type:
float
- get_value_inch100()[source]
Gets instance value in
1/100th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
float
- get_value_inch1000()[source]
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mmunits.- Returns:
Value in
mmunits.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to Size in
pt(points) units.- Returns:
Value in
ptunits.- Return type:
int
- get_value_px()[source]
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitInch100(value)[source]
Unit in
1/100th inunits.Supports
UnitTprotocol.See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- 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
- classmethod from_app_font(value, kind)[source]
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – 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_cm(value)[source]
Get instance from
cmvalue.- Parameters:
value (float) –
cmvalue.- Return type:
- classmethod from_in(value)
Get instance from
in(inch) value.- Parameters:
value (float) –
invalue.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in(inch) value.- Parameters:
value (float) –
invalue.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
- classmethod from_px(value)[source]
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
- classmethod from_unit_val(value)[source]
Get instance from
UnitTor float value.- Parameters:
value (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be ininch100units.- Return type:
- static get_unit_length()[source]
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.IN100.- Return type:
- 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_cm()[source]
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
int
- get_value_inch1000()[source]
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/1000th inchunits.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to Size in
mmunits.- Returns:
Value in
mmunits.- Return type:
int
- 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(points) units.- Returns:
Value in
ptunits.- Return type:
int
- get_value_px()[source]
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitInch1000(value)[source]
Represents
1/1,000th inunits.Supports
UnitTprotocol.See also
- Parameters:
value (int) –
- __init__(value)
- Parameters:
value (int) –
- Return type:
None
- 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
- classmethod from_app_font(value, kind)[source]
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – 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_cm(value)[source]
Get instance from
cmvalue.- Parameters:
value (int) –
cmvalue.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
`/10th invalue.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt(points) value.- Parameters:
value (int) –
ptvalue.- Return type:
- classmethod from_px(value)[source]
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
- classmethod from_unit_val(value)[source]
Get instance from
UnitTor float value.- Parameters:
value (UnitT, float, int) –
UnitTor float value. If float then it is assumed to be ininch1000units.- Return type:
- static get_unit_length()[source]
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.IN1000.- Return type:
- 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_cm()[source]
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
int
- get_value_inch1000()[source]
Gets instance value in
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mmunits.- Returns:
Value in
mmunits.- Return type:
int
- get_value_mm100()[source]
Gets instance value in
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to
pt(point) units.- Returns:
Value in
ptunits.- Return type:
int
- get_value_px()[source]
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
int
- value: int
Int value.
- class ooodev.units.UnitLength(value)[source]
An enumeration.
- CH = 18
210twip (14 px)- Type:
char unit
- CM = 3
centimeter
- COUNT = 20
- EMU = 6
1/360000 cm,1/914400 in- Type:
English Metric Unit
- FT = 14
foot
- IN = 13
inch
- IN10 = 12
1/10 in
- IN100 = 11
1/100 in
- IN1000 = 10
1/1000 in
- INVALID = -1
invalid
- KM = 5
kilometer
- LINE = 19
312twip- Type:
line unit
- M = 4
meter
- MASTER = 16
1/576 in- Type:
PPT Master Unit
- MI = 15
mile
- MM = 2
millimeter
- MM10 = 1
1/10 mm
- MM100 = 0
1/100th mm
- PC = 9
1/6 in- Type:
Pica
- PX = 17
15twip (96 ppi)- Type:
pixel unit
- TWIP = 7
1/20 pt- Type:
Twentieth of a point aka
dxa
- class ooodev.units.UnitMM(value)[source]
Unit in
mmunits.Supports
UnitTprotocol.See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- 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
- classmethod from_app_font(value, kind)[source]
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – 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_cm(value)[source]
Get instance from
cmvalue.- Parameters:
value (int) –
cmvalue.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
- classmethod from_px(value)[source]
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
- static get_unit_length()[source]
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.MM.- Return type:
- 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_cm()[source]
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
float
- get_value_inch()[source]
Gets instance value in
in(inch) units.- Returns:
Value in
inunits.- Return type:
float
- get_value_inch10()[source]
Gets instance value in
1/10th inchunits.- Returns:
Value in
1/10th inchunits.- Return type:
int
- get_value_inch100()[source]
Gets instance value in
1/100th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_inch1000()[source]
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- 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(points) 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
- value: float
Float value.
- class ooodev.units.UnitMM10(value)[source]
Unit in
1/10th mmunits.Supports
UnitTprotocol.See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- 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
- classmethod from_app_font(value, kind)[source]
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – 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_cm(value)[source]
Get instance from
cmvalue.- Parameters:
value (int) –
cmvalue.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
`/10th invalue.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
- classmethod from_px(value)[source]
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
- static get_unit_length()[source]
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.MM10.- Return type:
- 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_cm()[source]
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mmunits.- Returns:
Value in
mmunits.- Return type:
int
- get_value_mm10()[source]
Gets instance value in
1/10th mmunits.- Returns:
Value in
1/10th mmunits.- Return type:
float
- get_value_mm100()[source]
Gets instance value converted to
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to
pt(points) units.- Returns:
Value in
ptunits.- Return type:
int
- get_value_px()[source]
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitMM100(value)[source]
Represents
1/100th mmunits.Supports
UnitTprotocol.See also
- Parameters:
value (int) –
- __init__(value)
- Parameters:
value (int) –
- Return type:
None
- 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
- classmethod from_app_font(value, kind)[source]
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – 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_cm(value)[source]
Get instance from
cmvalue.- Parameters:
value (int) –
cmvalue.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
`/10th invalue.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt(points) value.- Parameters:
value (int) –
ptvalue.- Return type:
- classmethod from_px(value)[source]
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
- static get_unit_length()[source]
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.MM100.- Return type:
- 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_cm()[source]
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mmunits.- Returns:
Value in
mmunits.- Return type:
int
- get_value_mm10()[source]
Gets instance value in
1/10th mmunits.- Returns:
Value in
1/10th mmunits.- Return type:
float
- get_value_mm100()[source]
Gets instance value in
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_pt()[source]
Gets instance value converted to
pt(point) units.- Returns:
Value in
ptunits.- Return type:
int
- get_value_px()[source]
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
int
- value: int
Int value.
- class ooodev.units.UnitPT(value)[source]
Represents a
PT(points) value.Supports
UnitTprotocol.See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- 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
- classmethod from_app_font(value, kind)[source]
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – 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_cm(value)[source]
Get instance from
cmvalue.- Parameters:
value (int) –
cmvalue.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
- classmethod from_px(value)[source]
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
- static get_unit_length()[source]
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.PT.- Return type:
- 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_cm()[source]
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
int
- get_value_inch()[source]
Gets instance value in
in(inch) units.- Returns:
Value in
inunits.- Return type:
float
- get_value_inch10()[source]
Gets instance value in
1/10th inchunits.- Returns:
Value in
1/10th inchunits.- Return type:
int
- get_value_inch100()[source]
Gets instance value in
1/100th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_inch1000()[source]
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mmunits.- Returns:
Value in
mmunits.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_pt()[source]
Gets instance value in
pt(point) units.- Returns:
Value in
ptunits.- Return type:
int
- get_value_px()[source]
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
int
- value: float
Float value.
- class ooodev.units.UnitPX(value)[source]
Represents a
PX(pixel) value.Supports
UnitTprotocol.See also
- Parameters:
value (float) –
- __init__(value)
- Parameters:
value (float) –
- Return type:
None
- almost_equal(val, epsilon=1e-09)
Comparing float values directly using equality (
==) can sometimes lead to unexpected results due to the way floating-point numbers are represented in computers. A small rounding error can make two floats that should be equal appear unequal.A common way to compare floats is to check if the absolute difference between them is less than a small number, often called the machine epsilon.
In this function,
epsilonis the maximum difference for whichaandbare considered equal. You can adjustepsilonbased on the precision you need.- Parameters:
val (float) – The value to compare with.
epsilon (float) – The maximum difference for which
aandbare considered equal.
- Returns:
True if current value and
valare considered equal, False otherwise.- Return type:
bool
- 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
- classmethod from_app_font(value, kind)[source]
Get instance from
AppFontvalue.- Parameters:
value (int) –
AppFontvalue.kind (PointSizeKind, optional) – 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_cm(value)[source]
Get instance from
cmvalue.- Parameters:
value (int) –
cmvalue.- Return type:
- classmethod from_inch(value)[source]
Get instance from
in(inch) value.- Parameters:
value (int) –
invalue.- Return type:
- classmethod from_inch10(value)[source]
Get instance from
1/10th in(inch) value.- Parameters:
value (int) –
1/10th invalue.- Return type:
- classmethod from_inch100(value)[source]
Get instance from
1/100th in(inch) value.- Parameters:
value (int) –
1/100th invalue.- Return type:
- classmethod from_inch1000(value)[source]
Get instance from
1/1,000th in(inch) value.- Parameters:
value (int) –
1/1,000th invalue.- Return type:
- classmethod from_mm(value)[source]
Get instance from
mmvalue.- Parameters:
value (int) –
mmvalue.- Return type:
- classmethod from_mm10(value)[source]
Get instance from
1/10th mmvalue.- Parameters:
value (int) –
1/10th mmvalue.- Return type:
- classmethod from_mm100(value)[source]
Get instance from
1/100th mmvalue.- Parameters:
value (int) –
1/100th mmvalue.- Return type:
- classmethod from_pt(value)[source]
Get instance from
pt(points) value.- Parameters:
value (float) –
ptvalue.- Return type:
- classmethod from_px(value)[source]
Get instance from
px(pixel) value.- Parameters:
value (float) –
pxvalue.- Return type:
- static get_unit_length()[source]
Gets instance unit length.
- Returns:
Instance unit length
UnitLength.PX.- Return type:
- 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_cm()[source]
Gets instance value converted to
cmunits.- Returns:
Value in
cmunits.- Return type:
int
- get_value_inch()[source]
Gets instance value in
in(inch) units.- Returns:
Value in
inunits.- Return type:
float
- get_value_inch10()[source]
Gets instance value in
1/10th inchunits.- Returns:
Value in
1/10th inchunits.- Return type:
int
- get_value_inch100()[source]
Gets instance value in
1/100th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_inch1000()[source]
Gets instance value in
1/1000th inchunits.- Returns:
Value in
1/100th inchunits.- Return type:
int
- get_value_mm()[source]
Gets instance value converted to
mmunits.- Returns:
Value in
mmunits.- Return type:
int
- get_value_mm100()[source]
Gets instance value converted to
1/100th mmunits.- Returns:
Value in
1/100th mmunits.- Return type:
int
- get_value_pt()[source]
Gets instance value in
pt(point) units.- Returns:
Value in
ptunits.- Return type:
int
- get_value_px()[source]
Gets instance value in
px(pixel) units.- Returns:
Value in
pxunits.- Return type:
int
- value: float
Float value.
- ooodev.units.unit_factory.get_unit(unit_length, value)[source]
Gets the unit.
- Parameters:
unit_length (UnitLength) – Unit Length.
value (int | float) – Value.
- Returns:
Unit.
- Return type:
Example
>>> from ooodev.units.unit_factory import get_unit >>> from ooodev.units UnitLength >>> unit_mm100 = get_unit(UnitLength.MM100, 500) >>> print(unit_mm100) UnitMM100(value=500)
New in version 0.34.1.
- ooodev.units.unit_factory.get_unit_type(unit_length)[source]
Gets the unit type.
- Parameters:
unit_length (UnitLength) – Unit Length.
- Raises:
ValueError – If unknown unit length or there is not type to match the unit length.
- Returns:
Unit Type.
- Return type:
Type[UnitT]
Example
from ooodev.units.unit_factory import get_unit_type from ooodev.units UnitLength unit_mm100_type = get_unit_type(UnitLength.MM100)
New in version 0.34.1.