43 lines
No EOL
1 KiB
Markdown
43 lines
No EOL
1 KiB
Markdown
Intro
|
|
https://flet.dev/docs/
|
|
Flutter in python
|
|
|
|
- Installation
|
|
`pip install flet` (Need python version>3.8)
|
|
- Running code
|
|
`python counter.py`
|
|
- Sample code
|
|
```py
|
|
import flet as ft
|
|
|
|
def main(page: ft.Page):
|
|
page.title = "Flet counter example"
|
|
page.vertical_alignment = ft.MainAxisAlignment.CENTER
|
|
|
|
txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)
|
|
|
|
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(
|
|
ft.Row(
|
|
[
|
|
ft.IconButton(ft.icons.REMOVE, on_click=minus_click),
|
|
txt_number,
|
|
ft.IconButton(ft.icons.ADD, on_click=plus_click),
|
|
],
|
|
alignment=ft.MainAxisAlignment.CENTER,
|
|
)
|
|
)
|
|
|
|
ft.app(target=main)
|
|
```
|
|
- Packing
|
|
Need to install pyinstaller first using `pip install pyinstaller`
|
|
then
|
|
`flet pack counter.py` |