flet README

项目的 README,来自 github.com/flet-dev/flet。合并为一个 markdown 文件:README.md。

Flet logo

Build cross-platform apps in Python. No frontend experience required.

License Package version Monthly downloads Python >= 3.10 Build status Docstring coverage

Flet is a Python framework for building web, desktop, and mobile apps without prior experience in frontend development.

Try Flet online in Flet Studio

Create, run, and share Python apps in your browser. Start from an example, write your own code, or get help from the AI agent. No installation required.

   One Python codebase, six platforms

Build your interface and application logic in Python, and run your app on iOS, Android, Windows, macOS, Linux, and web. No Dart, Swift, Kotlin, HTML, or JavaScript required.

   150+ built-in controls and services

Create your interface with ready-made layouts, buttons, forms, navigation, and dialogs. Customize colors, typography, and themes, with Material and Cupertino controls to suit your app.

   Declarative UI for growing apps

Organize your app into reusable components and let the UI update when application state changes. Prefer changing controls directly? The imperative style is supported too. Compare the approaches.

   Your Python libraries, on mobile

Use libraries such as NumPy, pandas, Pillow, and cryptography in your mobile apps. Flet provides prebuilt binary packages for iOS and Android, so you don't have to compile native dependencies yourself.

   Run in the browser or on your server

Run Python directly in the browser with Pyodide and WebAssembly, with no Python server required. Or keep your Python code on a server and deliver real-time UI updates to the browser.

   Built-in packaging

Use flet build to package your app for desktop, mobile, or web distribution, including the App Store and Google Play. Configure dependencies, icons, and platform settings in your project's pyproject.toml.

   Test your app on desktop and mobile

Write integration tests with pytest and run them against your packaged app with flet test. Tap buttons, enter text, and verify user flows on desktop and mobile, with screenshot comparisons on Android and iOS.

   Build with help from AI

Explore and create apps with the AI agent in Flet Studio, or connect your coding assistant to the Flet MCP server for version-specific API information and tools to find examples and icons.

   Extensible

Build custom controls in Python by composing existing controls, or create extensions that wrap Flutter packages to add new UI components and platform integrations.

   Accessible

Add screen-reader labels, tooltips, keyboard shortcuts, and custom semantics to help more people use your app. Inspect the accessibility information your UI exposes with the semantics debugger.

Flet app example

This simple counter app displays a number in the center of the screen. Press the + button to increment it:

import flet as ft


def main(page: ft.Page):
    counter = ft.Text("0", size=50, data=0)

    def increment_click(e):
        counter.data += 1
        counter.value = str(counter.data)

    page.floating_action_button = ft.FloatingActionButton(
        icon=ft.Icons.ADD, on_click=increment_click
    )
    page.add(
        ft.SafeArea(
            expand=True,
            content=ft.Container(
                content=counter,
                alignment=ft.Alignment.CENTER,
            ),
        )
    )


ft.run(main)

To run the app, install flet:

pip install 'flet[all]'

Save the code as counter.py, then launch the app:

flet run counter.py

This opens the app in a native desktop window. The screenshot below shows it after pressing + three times:

To run the same app in your browser, add --web:

flet run --web counter.py

Learn more

Community

Contributing

Want to help improve Flet? Check out the contribution guide.

flet (flet-dev/flet)

正在搜索数据库…

17.6K ·GitHub
这是什么东西?Flet 是一个 Python 框架,只用一套 Python 代码就能构建网页、移动端和桌面应用——不需要任何前端经验,界面由 Flutter 负责渲染。
所以它是个框架,不是可视化应用构建器——那我实际要写什么?整个应用都用 Python 编写,使用 Flet 提供的控件;框架负责通过 Flutter 渲染界面、输出多平台版本以及打包。
我怎么把第一个应用跑起来?先安装 flet,然后用 'flet run' 启动——应用会在系统的原生窗口中打开;加上 '--web' 参数,就可以改成在浏览器里运行同一个应用。
除了 Python,我还需要 Dart、Swift 或 JavaScript 吗?不需要——只用 Python。Flet 甚至为 iOS 和 Android 内置了 50 多个常用的 Python 包,包括 numpy、pandas、pydantic、cryptography、opencv 和 pillow。
同一份代码真的能同时覆盖手机、桌面和浏览器吗?可以——一套代码可以面向 iOS、Android、Windows、Linux、macOS 和网页。在浏览器里,它通过 WebAssembly 和 Pyodide 原生运行,不需要服务器;也可以部署在服务器端,界面实时更新。
它自带哪些界面组件?内置 150 多个控件和服务,采用 Material 和 Cupertino 设计风格:包括布局、导航、对话框和图表。
开发的时候,我怎样在自己手机上测试应用?用 Flet App 在你自己的 iOS 或 Android 设备上打开项目,改动代码后就能看到更新实时出现。
做完的应用怎么分发出去?内置的打包功能可以生成独立的可执行文件或安装包,支持 iOS、Android、Windows、Linux、macOS 和网页,可以直接上架 App Store 和 Google Play。
Flet 没提供的控件,我能自己加吗?可以——把数千个现成的 Flutter 包封装后给 Flet 使用,或者用内置的 UI 基础组件,纯用 Python 编写全新的控件。
作者
flet-dev
大小
229.2 MB
星标
17.6K
时长
4年
提交 · 90 天