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_1andcondition_2are 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_1orcondition_2is 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
widthdivided 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-heightormax-height<value>is a fractional number<unit>can bepx,ptorsp
If the unit is omitted,
pxis assumed.See
new_length.Examples:
min-width: 500pxmin-height: 400ptmax-width: 100spmax-height: 500
Ratio conditions are specified as
<type>: <width>[/<height>], where:<type>can bemin-aspect-ratioormax-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/3max-aspect-ratio: 1
The logical operators
and,orcan 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/3max-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.