Curious George sees the world
 
Flet – Hello World

Flet – Hello World

Introduction to Flet


Flet is a framework that allows developers to use Python to build mobile, desktop and web applications, and Google’s Flutter to build user interfaces. It is a small and beautiful emerging framework.

Set up an environment

Code:


import flet as ft                                     

def main(page: ft.Page):                              

    page.add(ft.Text("Hello World!"))                

ft.app(target=main) 

Result:

Run python hello.py under command and you will see the following results

Flet Hello world 的執行結果
Note:

If you need to create a new flet application using flet create cmd, you need to install git. If git is not installed, you will receive the following error message:
cookiecutter.exceptions.VCSNotInstalled: ‘git’ is not installed.

Install git: https://git-scm.com/download/win

Source code: https://github.com/lcc728/flet/blob/main/Hello.py

——–正體中文—–

Flet 簡介

Flet 是一個框架,讓開發者能夠利用 python 來建立手機、 Desktop 和 web 的應用程式,利用 Google的 Flutter 來建立 UI,是一個小而美的新興框架

Flet : https://flet.dev/
Flutter : https://flutter.dev/
Python: https://www.python.org/

建立環境

安裝 Python: https://docs.python.org/3/using/index.html

安裝 Flet : https://flet.dev/docs/getting-started/create-flet-app

第一個程式

import flet as ft                                     #import Flet 模組

def main(page: ft.Page):                              #定義 Main,內有一個參數 page 用來定義各種 Flet 的元件 

    page.add(ft.Text("Hello World!"))                 #增加一個 flet 的 text widget, 裡面放 Hello world 的文字

ft.app(target=main)                                   # 指定 flet 的入口為 main 

執行結果:

在 command 下執行 python hello.py 就能看到以下的結果

Flet Hello world 的執行結果

備註:

如果需要執行 flet create 的命立來建立開發目錄和相關檔案,需安裝 git 才能運作,若無安裝 git 會出現這樣的錯誤訊息:
cookiecutter.exceptions.VCSNotInstalled: ‘git’ is not installed.

安裝 git : https://git-scm.com/download/win

Source code: https://github.com/lcc728/flet/blob/main/Hello.py

發表迴響