How to add more unique buttons in app? #1689
-
QuestionHi, I would like to know if it is possible to add more buttons in app, that each one is independent and that they can return unique values. This example adds 10 buttons but always gives the last value Code sampleimport flet as ft
def main(page: ft.Page):
r = ft.Row(wrap=True, scroll="always", expand=True)
page.add(r)
def pruebas(e):
print(e)
for i in range(10):
r.controls.append(ft.ElevatedButton(i, on_click=lambda _:pruebas(i)),)
page.update()
ft.app(target=main) Error messageNo response ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Answered by
ndonkoHenri
Aug 7, 2023
Replies: 1 comment 1 reply
-
You can do this: for i in range(10):
r.controls.append(ft.ElevatedButton(i, data=i, on_click=lambda e: pruebas(e.control.data))) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Davidm16
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can do this: