Flet for Python

0.84.0 · active · verified Wed Apr 15

Flet is a Python library for easily building interactive multi-platform apps using Flutter under the hood. It allows developers to create beautiful desktop, web, and mobile applications with pure Python, leveraging a declarative UI framework. Currently at version 0.84.0, Flet maintains a rapid release cadence, often with weekly development builds and bi-weekly stable releases.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a simple counter application. It showcases basic UI components like `Text` and `IconButton`, event handling (`on_click`), and the critical `page.update()` method for refreshing the UI after state changes.

import flet as ft

def main(page: ft.Page):
    page.title = "Flet Counter App"
    page.vertical_alignment = ft.MainAxisAlignment.CENTER

    txt_number = ft.Text("0", size=30)

    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)

view raw JSON →