LayoutControl
Inherits: Control
Properties
-
align(Optional[Alignment]) –Alignment of the control within its parent.
-
animate_align(Optional[AnimationValue]) –Enables implicit animation of the
alignproperty. -
animate_margin(Optional[AnimationValue]) –Enables implicit animation of the
marginproperty. -
animate_offset(Optional[AnimationValue]) –Enables implicit animation of the
offsetproperty. -
animate_opacity(Optional[AnimationValue]) –Enables implicit animation of the
opacityproperty. -
animate_position(Optional[AnimationValue]) – -
animate_rotation(Optional[AnimationValue]) –Enables implicit animation of the
rotateproperty. -
animate_scale(Optional[AnimationValue]) –Enables implicit animation of the
scaleproperty. -
animate_size(Optional[AnimationValue]) –TBD
-
aspect_ratio(Optional[Number]) –The aspect ratio of the control.
-
bottom(Optional[Number]) –The distance that the child's bottom edge is inset from the bottom of the stack.
-
height(Optional[Number]) –Imposed Control height in virtual pixels.
-
left(Optional[Number]) –The distance that the child's left edge is inset from the left of the stack.
-
margin(Optional[MarginValue]) –Sets the margin of the control.
-
offset(Optional[OffsetValue]) –Applies a translation transformation before painting the control.
-
right(Optional[Number]) –The distance that the child's right edge is inset from the right of the stack.
-
rotate(Optional[RotateValue]) –Transforms this control using a rotation around its center.
-
scale(Optional[ScaleValue]) –Scales this control along the 2D plane. Default scale factor is
1.0, meaning no-scale. -
size_change_interval(int) –Sampling interval in milliseconds for
on_size_changeevent. -
top(Optional[Number]) –The distance that the child's top edge is inset from the top of the stack.
-
width(Optional[Number]) –Imposed Control width in virtual pixels.
Events
-
on_animation_end(Optional[ControlEventHandler[LayoutControl]]) –Called when animation completes.
-
on_size_change(Optional[EventHandler[LayoutSizeChangeEvent[LayoutControl]]]) –Called when the size of this control changes.
Properties#
align
class-attribute
instance-attribute
#
Alignment of the control within its parent.
animate_align
class-attribute
instance-attribute
#
animate_align: Optional[AnimationValue] = None
animate_margin
class-attribute
instance-attribute
#
animate_margin: Optional[AnimationValue] = None
animate_offset
class-attribute
instance-attribute
#
animate_offset: Optional[AnimationValue] = None
animate_opacity
class-attribute
instance-attribute
#
animate_opacity: Optional[AnimationValue] = None
animate_position
class-attribute
instance-attribute
#
animate_position: Optional[AnimationValue] = None
animate_rotation
class-attribute
instance-attribute
#
animate_rotation: Optional[AnimationValue] = None
animate_scale
class-attribute
instance-attribute
#
animate_scale: Optional[AnimationValue] = None
aspect_ratio
class-attribute
instance-attribute
#
The aspect ratio of the control. It is defined as the ratio of the width to the height.
bottom
class-attribute
instance-attribute
#
The distance that the child's bottom edge is inset from the bottom of the stack.
Note
Effective only if this control is a descendant of one of the following:
Stack control, Page.overlay list.
height
class-attribute
instance-attribute
#
Imposed Control height in virtual pixels.
left
class-attribute
instance-attribute
#
The distance that the child's left edge is inset from the left of the stack.
Note
Effective only if this control is a descendant of one of the following:
Stack control, Page.overlay list.
margin
class-attribute
instance-attribute
#
margin: Optional[MarginValue] = None
Sets the margin of the control.
offset
class-attribute
instance-attribute
#
offset: Optional[OffsetValue] = None
Applies a translation transformation before painting the control.
The translation is expressed as an Offset scaled to the control's size.
So, Offset(x=0.25, y=0), for example, will result in a horizontal translation
of one quarter the width of this control.
Example
The following example displays container at 0, 0 top left corner of a stack
as transform applies -1 * 100, -1 * 100 (offset * control's size)
horizontal and vertical translations to the control:
```python
import flet as ft
def main(page: ft.Page):
page.add(
ft.Stack(
width=1000,
height=1000,
controls=[
ft.Container(
bgcolor=ft.Colors.RED,
width=100,
height=100,
left=100,
top=100,
offset=ft.Offset(-1, -1),
)
],
)
)
ft.run(main)
```
right
class-attribute
instance-attribute
#
The distance that the child's right edge is inset from the right of the stack.
Note
Effective only if this control is a descendant of one of the following:
Stack control, Page.overlay list.
rotate
class-attribute
instance-attribute
#
rotate: Optional[RotateValue] = None
Transforms this control using a rotation around its center.
The value of rotate property could be one of the following types:
number- a rotation in clockwise radians. Full circle360°ismath.pi * 2radians,90°ispi / 2,45°ispi / 4, etc.Rotate- allows to specify rotationangleas well asalignment- the location of rotation center.
scale
class-attribute
instance-attribute
#
scale: Optional[ScaleValue] = None
Scales this control along the 2D plane. Default scale factor is 1.0, meaning no-scale.
Setting this property to 0.5, for example, makes this control twice smaller,
while 2.0 makes it twice larger.
Different scale multipliers can be specified for x and y axis, by setting
Control.scale property to an instance of Scale class.
Either scale or scale_x and scale_y could be specified, but not all of them.
size_change_interval
class-attribute
instance-attribute
#
size_change_interval: int = 10
Sampling interval in milliseconds for on_size_change event.
Setting to 0 calls on_size_change immediately
on every change.
top
class-attribute
instance-attribute
#
The distance that the child's top edge is inset from the top of the stack.
Note
Effective only if this control is a descendant of one of the following:
Stack control, Page.overlay list.
width
class-attribute
instance-attribute
#
Imposed Control width in virtual pixels.
Events#
on_animation_end
class-attribute
instance-attribute
#
on_animation_end: Optional[
ControlEventHandler[LayoutControl]
] = None
Called when animation completes.
Can be used to chain multiple animations.
The data property of the event handler argument contains the name
of the animation.
More information here.
on_size_change
class-attribute
instance-attribute
#
on_size_change: Optional[
EventHandler[LayoutSizeChangeEvent[LayoutControl]]
] = None
Called when the size of this control changes.
size_change_interval defines how often this event is called.