Their description is
The fastest way to build Flutter apps in Python
Flet enables developers to easily build realtime web, mobile and desktop apps in Python. No frontend experience required.
As an experiment I decided to create a simple login form.
import flet as ft
def main(page: ft.Page):
page.title = "Login"
page.window_height = 200
page.window_width = 500
page.window_always_on_top = True
def cancel_click(e):
page.window_destroy()
def login_click(e):
if txt_user.value == "admin" and txt_pwd.value == "admin":
dlg.content = ft.Text("Login Successful")
else:
dlg.content = ft.Text("Login failed")
dlg.modal = False
dlg.open = True
dlg.update()
page.update()
dlg = ft.AlertDialog(title=ft.Text("Login"), content=ft.Text("---"))
txt_user = ft.TextField(value = "", label="User ID")
txt_pwd = ft.TextField(value = "", password=True, can_reveal_password=True,
label="Password")
btn_cancel = ft.FilledButton(text="Cancel", on_click=cancel_click)
btn_login = ft.FilledButton(text="Login", on_click=login_click)
action_row = ft.Row(controls=[btn_cancel, btn_login])
page.add(txt_user, txt_pwd, action_row, dlg)
page.window_center()
ft.app(target=main)
This results in the following window
A jupyter notebook is here.
No comments:
Post a Comment