Issue
I use Flet Python framework And I want to delete its values after clicking on the button and store them in the data table
def main(page: ft.Page):
def btn_click(e):
if not sstid.value:
sstid.error_text = "err"
page.update()
else:
my_dict["sstid"] = sstid.value
page.update()
page.add(
ft.Container(
height=250,
# bgcolor="white10",
bgcolor="white10",
border=border.all(1,"#ebebeb"),
border_radius=8,
padding=15,
content=Column(
expand=True,
controls=[
ft.ElevatedButton("add", on_click=btn_click),
],
)
)
Solution
def main(page: ft.Page):
my_dict = {}
def btn_click(e):
if not sstid.value:
sstid.error_text = "err"
page.update()
else:
my_dict["sstid"] = sstid.value
sstid.set_value("") # clear the value of sstid
page.update()
sstid = ft.TextField(label="SSTID", name="sstid")
page.add(
ft.Container(
height=250,
bgcolor="white10",
border=border.all(1,"#ebebeb"),
border_radius=8,
padding=15,
content=Column(
expand=True,
controls=[
sstid,
ft.ElevatedButton("Add", on_click=btn_click),
],
),
)
)
Answered By - NoobCoder
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.