search
HomeBackend DevelopmentPython TutorialFlet: a cross-platform Flutter-based Python framework

Flet: a cross-platform Flutter-based Python framework

Apr 20, 2023 pm 05:46 PM
Front-end developmentflet

Flet: a cross-platform Flutter-based Python framework

I just posted a micro-headline about the complete collection of Python desktop development libraries yesterday, and my colleague discovered the Flet library. This is a very new library. The first version was only released in June this year. Although it is very new, it is backed by the giant Flutter and allows us to use Python to develop full-platform software. Although it does not currently support all platforms, According to the author’s plan, whatever Flutter supports, it will support in the future. I briefly studied it yesterday and it’s really great. I recommend it to everyone. We can use it to do a series of things later.

What is Flet

Flet is a framework that allows building interactive multi-user web, desktop and mobile applications in your favorite language without having to have experience with front-end development.

Key Features

Go from idea to application in minutes

Apps for your team, weekend projects, data entry forms, kiosk applications or high-fidelity prototypes of in-house tools or dashboards - Flet is an ideal framework for quickly hacking together a beautiful, interactive application that serves a group of users.

Simple Architecture

No more complex architecture with JavaScript frontend, REST API backend, database, cache, etc. With Flet, you can get a multi-user real-time single-page application (SPA) simply by writing a monolithic stateful application in Python.

Battery included

To start developing with Flet, all you need is your favorite IDE or text editor. No SDK, no thousands of dependencies, no complex tools - Flet has a built-in web server that includes managed assets and a desktop client.

Powered by Flutter

Flet UI is built with Flutter so your app looks professional and ready to be delivered to any platform. Flet simplifies the Flutter model by combining smaller "widgets" into ready-to-use "controls" with an imperative programming model.

Language agnostic

Flet is language agnostic, so anyone on your team can develop Flet applications in their favorite language. Python is already supported, with Go, C# and other products not far behind .

Delivery to any device

Deploy your Flet app as a web app and view it in a browser. Package it as a standalone desktop application for Windows, macOS, and Linux. Install it as a PWA on your mobile device or view it via the Flet app for iOS and Android.

Installation and use

pip install flet

A simple counting example

import flet
from flet import IconButton, Page, Row, TextField, icons
def main(page: Page):
page.title = "Flet counter example"
page.vertical_alignment = "center"

txt_number = TextField(value="0", text_align="right", width=100)

def minus_click(e):
txt_number.value = int(txt_number.value) - 1
page.update()

def plus_click(e):
txt_number.value = int(txt_number.value) + 1
page.update()

page.add(
Row(
[
IconButton(icons.REMOVE, on_click=minus_click),
txt_number,
IconButton(icons.ADD, on_click=plus_click),
],
alignment="center",
)
)

flet.app(target=main)

Run the program:

python counter.py

Flet: a cross-platform Flutter-based Python framework

How We want it to run only on the browser side, which can be configured as follows:

flet.app(target=main, view=flet.WEB_BROWSER)

The default is to run the desktop side, but when we start it, a web server will be started on a random port, which can also be accessed on the web side.

Flet: a cross-platform Flutter-based Python framework

This is a simple example given by the official. Let’s write a slightly more complicated one: a calculator.

Flet: a cross-platform Flutter-based Python framework

The page has a lot of code, but it is quite simple, so I won’t post it. You can see that even if you use native controls to spell out the page, the effect is pretty good, which is better than other Python Desktop development libraries are much nicer to look at. Although it does not have an interface designer like QT, which can generate pages by dragging and dropping, its layout method is the same as that of the front-end, so it is very familiar to developers who know the front-end and is very convenient to use.

Summary

At present, this project is only a BETA version, and the official documentation is not complete enough, but it is still no problem for developing some basic software. Especially based on Flutter, there is no need to package the chromium core like Electron. After accessing multiple languages ​​later, it will provide many programmers with an excellent cross-platform development method. They do not need a specific development language to get started like Electron and Flutter. We look forward to it becoming more complete. Later we can try some more gadgets to practice our skills.

The above is the detailed content of Flet: a cross-platform Flutter-based Python framework. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:51CTO.COM. If there is any infringement, please contact admin@php.cn delete
Are Python lists dynamic arrays or linked lists under the hood?Are Python lists dynamic arrays or linked lists under the hood?May 07, 2025 am 12:16 AM

Pythonlistsareimplementedasdynamicarrays,notlinkedlists.1)Theyarestoredincontiguousmemoryblocks,whichmayrequirereallocationwhenappendingitems,impactingperformance.2)Linkedlistswouldofferefficientinsertions/deletionsbutslowerindexedaccess,leadingPytho

How do you remove elements from a Python list?How do you remove elements from a Python list?May 07, 2025 am 12:15 AM

Pythonoffersfourmainmethodstoremoveelementsfromalist:1)remove(value)removesthefirstoccurrenceofavalue,2)pop(index)removesandreturnsanelementataspecifiedindex,3)delstatementremoveselementsbyindexorslice,and4)clear()removesallitemsfromthelist.Eachmetho

What should you check if you get a 'Permission denied' error when trying to run a script?What should you check if you get a 'Permission denied' error when trying to run a script?May 07, 2025 am 12:12 AM

Toresolvea"Permissiondenied"errorwhenrunningascript,followthesesteps:1)Checkandadjustthescript'spermissionsusingchmod xmyscript.shtomakeitexecutable.2)Ensurethescriptislocatedinadirectorywhereyouhavewritepermissions,suchasyourhomedirectory.

How are arrays used in image processing with Python?How are arrays used in image processing with Python?May 07, 2025 am 12:04 AM

ArraysarecrucialinPythonimageprocessingastheyenableefficientmanipulationandanalysisofimagedata.1)ImagesareconvertedtoNumPyarrays,withgrayscaleimagesas2Darraysandcolorimagesas3Darrays.2)Arraysallowforvectorizedoperations,enablingfastadjustmentslikebri

For what types of operations are arrays significantly faster than lists?For what types of operations are arrays significantly faster than lists?May 07, 2025 am 12:01 AM

Arraysaresignificantlyfasterthanlistsforoperationsbenefitingfromdirectmemoryaccessandfixed-sizestructures.1)Accessingelements:Arraysprovideconstant-timeaccessduetocontiguousmemorystorage.2)Iteration:Arraysleveragecachelocalityforfasteriteration.3)Mem

Explain the performance differences in element-wise operations between lists and arrays.Explain the performance differences in element-wise operations between lists and arrays.May 06, 2025 am 12:15 AM

Arraysarebetterforelement-wiseoperationsduetofasteraccessandoptimizedimplementations.1)Arrayshavecontiguousmemoryfordirectaccess,enhancingperformance.2)Listsareflexiblebutslowerduetopotentialdynamicresizing.3)Forlargedatasets,arrays,especiallywithlib

How can you perform mathematical operations on entire NumPy arrays efficiently?How can you perform mathematical operations on entire NumPy arrays efficiently?May 06, 2025 am 12:15 AM

Mathematical operations of the entire array in NumPy can be efficiently implemented through vectorized operations. 1) Use simple operators such as addition (arr 2) to perform operations on arrays. 2) NumPy uses the underlying C language library, which improves the computing speed. 3) You can perform complex operations such as multiplication, division, and exponents. 4) Pay attention to broadcast operations to ensure that the array shape is compatible. 5) Using NumPy functions such as np.sum() can significantly improve performance.

How do you insert elements into a Python array?How do you insert elements into a Python array?May 06, 2025 am 12:14 AM

In Python, there are two main methods for inserting elements into a list: 1) Using the insert(index, value) method, you can insert elements at the specified index, but inserting at the beginning of a large list is inefficient; 2) Using the append(value) method, add elements at the end of the list, which is highly efficient. For large lists, it is recommended to use append() or consider using deque or NumPy arrays to optimize performance.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download

Atom editor mac version download

The most popular open source editor