-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
42 lines (35 loc) · 1.19 KB
/
main.py
File metadata and controls
42 lines (35 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import flet as ft
def main(page: ft.Page):
page.title = "PyFlet"
page.vertical_alignment = ft.MainAxisAlignment.CENTER
txt_number = ft.TextField(value="0", text_align=ft.TextAlign.CENTER, width=150)
def btn_click(e):
if not txt_name.value:
txt_name.error_text = "Please enter your name"
page.update()
else:
name = txt_name.value
page.remove(txt_name, bt1)
page.add(ft.Text(f"Hello, {name}!"))
txt_name = ft.TextField(label="Your name")
bt1 = ft.ElevatedButton("Say hello!", on_click=btn_click)
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(
txt_name,
bt1,
ft.Row(
[
ft.IconButton(ft.icons.REMOVE, on_click=minus_click),
txt_number,
ft.IconButton(ft.icons.ADD, on_click=plus_click, on_focus=plus_click),
],
alignment=ft.MainAxisAlignment.CENTER,
)
)
#ft.app(target=main)
ft.app(target=main, view=ft.AppView.WEB_BROWSER)