How Do I Get The Value of a FilledButton or Text control Nested Inside of a ListView? #938
Answered
by
ndonkoHenri
AaronCatolico
asked this question in
Q&A
-
Say that I have a ListView that has either a Text or FilledButton nested inside of it, how do I get the value on_click when one of the items inside of the ListView is clicked? Here's what I'm working with:
|
Beta Was this translation helpful? Give feedback.
Answered by
ndonkoHenri
Jan 28, 2023
Replies: 1 comment 4 replies
-
Modify the line in the for loop as follows: lv.controls.append(FilledButton(text=f"# {i}", data=i, on_click=lambda e: show_item(e.control.data))) All Flet controls have a Let me know if it works as expected after this fix. |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
AaronCatolico
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Modify the line in the for loop as follows:
All Flet controls have a
data
property, which takes any python data type (int, list, dict etc).So, you store the
i
in there, and get it back usinge.control.data
.Let me know if it works as expected after this fix.