initial
This commit is contained in:
commit
74ae93a96e
1 changed files with 94691 additions and 0 deletions
43
joplin notion extension/Web Development/Python/Flet/Intro.md
Normal file
43
joplin notion extension/Web Development/Python/Flet/Intro.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
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`
|
||||
Loading…
Reference in a new issue