BreakpointCondition#
Added in version 1.4.
- class BreakpointCondition(*args, **kwargs)#
Describes condition for an Breakpoint
.
Constructors#
- class BreakpointCondition
- classmethod new_and(condition_1: BreakpointCondition, condition_2: BreakpointCondition) BreakpointCondition #
Creates a condition that triggers when
condition_1
andcondition_2
are both true.Added in version 1.4.
- Parameters:
condition_1 – first condition
condition_2 – second condition
- classmethod new_length(type: BreakpointConditionLengthType, value: float, unit: LengthUnit) BreakpointCondition #
Creates a condition that triggers on length changes.
Added in version 1.4.
- Parameters:
type – the length type
value – the length value
unit – the length unit
- classmethod new_or(condition_1: BreakpointCondition, condition_2: BreakpointCondition) BreakpointCondition #
Creates a condition that triggers when either
condition_1
orcondition_2
is true.Added in version 1.4.
- Parameters:
condition_1 – first condition
condition_2 – second condition
- classmethod new_ratio(type: BreakpointConditionRatioType, width: int, height: int) BreakpointCondition #
Creates a condition that triggers on ratio changes.
The ratio is represented as
width
divided byheight
.Added in version 1.4.
- Parameters:
type – the ratio type
width – ratio width
height – ratio height
Methods#
- class BreakpointCondition
-
- classmethod parse() BreakpointCondition #
Parses a condition from a string.
Length conditions are specified as
<type>: <value>[<unit>]
, where:<type>
can bemin-width
,max-width
,min-height
ormax-height
<value>
is a fractional number<unit>
can bepx
,pt
orsp
If the unit is omitted,
px
is assumed.See
new_length
.Examples:
min-width: 500px
min-height: 400pt
max-width: 100sp
max-height: 500
Ratio conditions are specified as
<type>: <width>[/<height>]
, where:<type>
can bemin-aspect-ratio
ormax-aspect-ratio
<width>
and<height>
are integer numbers
See
new_ratio
.The ratio is represented as
<width>
divided by<height>
.If
<height>
is omitted, it’s assumed to be 1.Examples:
min-aspect-ratio: 4/3
max-aspect-ratio: 1
The logical operators
and
,or
can be used to compose a complex condition as follows:<condition> and <condition>
: the condition is true when both<condition>
s are true, same as when usingnew_and
<condition> or <condition>
: the condition is true when either of the<condition>
s is true, same as when usingnew_or
Examples:
min-width: 400px and max-aspect-ratio: 4/3
max-width: 360sp or max-width: 360px
Conditions can be further nested using parentheses, for example:
min-width: 400px and (max-aspect-ratio: 4/3 or max-height: 400px)
If parentheses are omitted, the first operator takes priority.
Added in version 1.4.