flet
flet copied to clipboard
BrokenPipeError: [Errno 32] Broken pipe
I get this error when I close the page by clicking on the close icon.
import flet as ft
dosya = open("urun.txt", "a")
def main2(page: ft.Page):
txt_urad = ft.Text("Ürün Adı", width=120)
txt_fld_urad = ft.TextField(autofocus=True, expand=True)
row_urad = ft.Row(controls=[txt_urad, txt_fld_urad], width=float("inf"))
txt_fyt = ft.Text("Ürün Fiyatı", width=120)
txt_fld_fyt = ft.TextField(expand=True)
row_urfyt = ft.Row(controls=[txt_fyt, txt_fld_fyt], width=float("inf"))
lstview = ft.ListView(
height=float("inf"),
spacing=10,
padding=3,
auto_scroll=True,
)
def kaydet(e):
global dosya
dosya.write(f"{txt_fld_urad.value},{txt_fld_fyt.value}\n")
dosya.flush()
page.update()
def cikis(e):
print("cikis metodu calisti...")
global dosya
dosya.close()
page.window_close()
def lstview_ekle(e):
pass
btn_kaydet = ft.ElevatedButton(text="KAYDET", on_click=kaydet,
style=ft.ButtonStyle(shape={"": ft.RoundedRectangleBorder(radius=10)}),
bgcolor=ft.colors.SURFACE_VARIANT)
btn_cikis = ft.ElevatedButton(text="ÇIKIŞ", on_click=cikis)
row_btn = ft.Row(controls=[btn_kaydet, btn_cikis], width=float("inf"), alignment=ft.MainAxisAlignment.END)
page.add(
row_urad,
row_urfyt,
row_btn,
lstview
)
page.window_always_on_top = True
page.update()
ft.app(target=main2, name="main2", port=5555)
Error output
Traceback (most recent call last):
File "/xxx/xxy/main2.py", line 55, in
OS and Flet Version Os: Debian 12 Flet Version: 0.21.2 Python Version: 3.12.2
try with python 3.11.6