Skip to main content

PaintingStyle

Strategy used by flet.Paint.style when drawing geometry.

Determines whether a shape is rendered as a filled interior or as an outlined contour.

Inherits: enum.Enum

Properties

Examples

Showcase

import flet as ft
import flet.canvas as cv


def showcase_card(style: ft.PaintingStyle) -> ft.Container:
return ft.Container(
width=250,
padding=12,
border=ft.Border.all(1, ft.Colors.RED),
border_radius=10,
bgcolor=ft.Colors.SURFACE_CONTAINER_LOW,
content=ft.Column(
spacing=8,
controls=[
ft.Text(style.name, weight=ft.FontWeight.BOLD),
cv.Canvas(
width=240,
height=110,
shapes=[
cv.Circle(
x=120,
y=55,
radius=34,
paint=ft.Paint(
style=style,
stroke_width=10,
color=ft.Colors.PRIMARY,
),
)
],
),
],
),
)


def main(page: ft.Page):
page.horizontal_alignment = ft.CrossAxisAlignment.CENTER

page.appbar = ft.AppBar(title="PaintingStyle Showcase")
page.add(
ft.SafeArea(
content=ft.Column(
controls=[
ft.Text("Compare filled vs outlined rendering for the same shape."),
ft.Row(
wrap=True,
spacing=12,
expand=True,
scroll=ft.ScrollMode.AUTO,
alignment=ft.MainAxisAlignment.CENTER,
controls=[showcase_card(style) for style in ft.PaintingStyle],
),
],
),
)
)


if __name__ == "__main__":
ft.run(main)

Properties

FILLclass-attributeinstance-attribute

Paint the interior of the shape.

For example, circles and polygons are rendered as solid filled regions.

STROKEclass-attributeinstance-attribute

Paint only the shape outline.

Stroke thickness and joins/caps are controlled by properties such as flet.Paint.stroke_width, flet.Paint.stroke_join, and flet.Paint.stroke_cap.