InteractiveViewer
Examples#
Handling events#
import flet as ft
def main(page: ft.Page):
page.add(
ft.InteractiveViewer(
min_scale=0.1,
max_scale=15,
boundary_margin=ft.margin.all(20),
on_interaction_start=lambda e: print(e),
on_interaction_end=lambda e: print(e),
on_interaction_update=lambda e: print(e),
content=ft.Image(
src="https://picsum.photos/500/500",
),
)
)
ft.run(main)
InteractiveViewer
#
Bases: LayoutControl
Allows you to pan, zoom, and rotate its content.
| RAISES | DESCRIPTION |
|---|---|
AssertionError
|
If |
AssertionError
|
If |
AssertionError
|
If |
AssertionError
|
If |
AssertionError
|
If |
boundary_margin
#
boundary_margin: MarginValue = 0
A margin for the visible boundaries of the content.
constrained
#
constrained: bool = True
Whether the normal size constraints at this point in the widget tree are applied to the child.
interaction_end_friction_coefficient
#
interaction_end_friction_coefficient: Number = 1.35e-05
Changes the deceleration behavior after a gesture.
Note
Must be greater than 0.
interaction_update_interval
#
interaction_update_interval: int = 200
The interval (in milliseconds) at which the on_interaction_update event is fired.
max_scale
#
max_scale: Number = 2.5
The maximum allowed scale.
Note
Must be greater than or equal to min_scale.
min_scale
#
min_scale: Number = 0.8
The minimum allowed scale.
Note
Must be greater than 0 and less than or equal
to max_scale.
on_interaction_end
#
on_interaction_end: (
EventHandler[ScaleEndEvent[InteractiveViewer]] | None
) = None
Called when the user ends a pan or scale gesture.
on_interaction_start
#
on_interaction_start: (
EventHandler[ScaleStartEvent[InteractiveViewer]] | None
) = None
Called when the user begins a pan or scale gesture.
on_interaction_update
#
on_interaction_update: (
EventHandler[ScaleUpdateEvent[InteractiveViewer]] | None
) = None
Called when the user updates a pan or scale gesture.