Flet is a rich User Interface framework to quickly build interactive web, desktop and mobile apps in Python without prior knowledge of web technologies.
npx @tessl/cli install tessl/pypi-flet@0.28.0Flet is a rich User Interface (UI) framework to quickly build interactive web, desktop and mobile apps in Python without prior knowledge of web technologies. Built on Flutter's widget system, it provides an imperative programming model that simplifies UI development while maintaining professional-grade aesthetics and performance across all platforms.
pip install fletCreate a simple "Hello, World!" application:
import flet as ft
def main(page: ft.Page):
page.title = "Flet counter example"
page.vertical_alignment = ft.MainAxisAlignment.CENTER
txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)
def minus_click(e):
txt_number.value = str(int(txt_number.value) - 1)
page.update()
def plus_click(e):
txt_number.value = str(int(txt_number.value) + 1)
page.update()
page.add(
ft.Row(
[
ft.IconButton(ft.icons.REMOVE, on_click=minus_click),
txt_number,
ft.IconButton(ft.icons.ADD, on_click=plus_click),
],
alignment=ft.MainAxisAlignment.CENTER,
)
)
ft.app(target=main)Flet follows a page-based, event-driven architecture:
def app(
target: callable,
name: str = "",
host: str = None,
port: int = 0,
view: Optional[AppView] = AppView.FLET_APP,
assets_dir: str = "assets",
upload_dir: str = None,
web_renderer: WebRenderer = WebRenderer.CANVAS_KIT,
use_color_emoji: bool = False,
route_url_strategy: str = "path",
export_asgi_app: bool = False
) -> NoneMain synchronous application entry point.
Parameters:
target (callable): The main function to runname (str, optional): App namehost (str, optional): Server hostport (int, optional): Server portview (AppView, optional): App view type (FLET_APP, WEB_BROWSER, etc.)assets_dir (str, optional): Assets directory pathupload_dir (str, optional): Upload directory pathweb_renderer (WebRenderer, optional): Web renderer typeuse_color_emoji (bool, optional): Enable color emojiroute_url_strategy (str, optional): URL routing strategyexport_asgi_app (bool, optional): Export as ASGI appasync def app_async(
target: callable,
name: str = "",
host: str = None,
port: int = 0,
view: Optional[AppView] = AppView.FLET_APP,
assets_dir: str = "assets",
upload_dir: str = None,
web_renderer: WebRenderer = WebRenderer.CANVAS_KIT,
use_color_emoji: bool = False,
route_url_strategy: str = "path"
) -> NoneMain asynchronous application entry point with the same parameters as app() except export_asgi_app.
Flet provides comprehensive capabilities across multiple areas:
Key Controls:
Column, Row, Container, Stack, GridView, ListViewTextField, Checkbox, Radio, Switch, Slider, DropdownButton, ElevatedButton, IconButton, FloatingActionButtonText, Icon, Image, Card, ListTile, DataTable→ Complete UI Controls Reference
Key Navigation Controls:
AppBar, CupertinoAppBar, BottomAppBarNavigationBar, NavigationRail, NavigationDrawerTabs, Tab, MenuBar→ Layout and Navigation Reference
Chart Types:
BarChart, LineChart, PieChartMatplotlibChart, PlotlyChart→ Charts and Visualization Reference
Core Theming:
Theme, ColorScheme, TextThemeColors, CupertinoColors→ Theming and Styling Reference
Flet includes advanced capabilities for professional applications:
2D Graphics and Canvas:
Interactive Maps:
Media and System Integration:
→ Events and Interaction Reference
→ Utilities and Platform Reference
class Page:
"""Main page container for Flet applications."""
title: str
route: str
horizontal_alignment: CrossAxisAlignment
vertical_alignment: MainAxisAlignment
theme_mode: ThemeMode
theme: Theme
bgcolor: str
width: float
height: float
window_width: float
window_height: float
window_resizable: bool
window_maximizable: bool
window_minimizable: bool
def add(self, *controls: Control) -> None:
"""Add controls to the page."""
def update(self) -> None:
"""Update the page and all its controls."""
def go(self, route: str) -> None:
"""Navigate to a specific route."""
def show_dialog(self, dialog: AlertDialog) -> None:
"""Show a modal dialog."""
def show_snack_bar(self, snack_bar: SnackBar) -> None:
"""Show a snack bar notification."""class AppView(Enum):
"""Application view types."""
FLET_APP = "flet_app"
WEB_BROWSER = "web_browser"
FLET_APP_HIDDEN = "flet_app_hidden"
class WebRenderer(Enum):
"""Web renderer options."""
AUTO = "auto"
HTML = "html"
CANVAS_KIT = "canvaskit"
class ThemeMode(Enum):
"""Theme mode options."""
SYSTEM = "system"
LIGHT = "light"
DARK = "dark"
class MainAxisAlignment(Enum):
"""Main axis alignment options."""
START = "start"
END = "end"
CENTER = "center"
SPACE_BETWEEN = "spaceBetween"
SPACE_AROUND = "spaceAround"
SPACE_EVENLY = "spaceEvenly"
class CrossAxisAlignment(Enum):
"""Cross axis alignment options."""
START = "start"
END = "end"
CENTER = "center"
STRETCH = "stretch"
BASELINE = "baseline"import flet as ft
def main(page: ft.Page):
page.add(
ft.ResponsiveRow([
ft.Container(
ft.Text("Column 1"),
col={"sm": 6, "md": 4, "xl": 2}
),
ft.Container(
ft.Text("Column 2"),
col={"sm": 6, "md": 8, "xl": 10}
)
])
)import flet as ft
def main(page: ft.Page):
def button_clicked(e):
page.add(ft.Text("Button clicked!"))
page.update()
page.add(
ft.ElevatedButton("Click me!", on_click=button_clicked)
)import flet as ft
def main(page: ft.Page):
page.theme_mode = ft.ThemeMode.DARK
page.theme = ft.Theme(
color_scheme_seed=ft.colors.GREEN
)
page.update()This documentation is organized into specialized sections due to Flet's extensive API surface (450+ symbols):
pip install fletFlet enables rapid development of professional cross-platform applications with Python, eliminating the need for separate frontend technologies while providing native-looking results on all platforms.