-
|
Hi all, I create buttons dynamically after loading a json file like so: i = 0
for users in settings["users"]:
user_buttons[i] = ui.button(users['name'], on_click=lambda: set_userto(users['id']))
i = i+1Problem is ALL buttons call set_userto(4) Any ideas? |
Beta Was this translation helpful? Give feedback.
Answered by
rodja
Mar 8, 2023
Replies: 2 comments 3 replies
-
|
You need to capture the value of users at the time each button is created: for i, user in enumerate(settings["users"]):
user_buttons[i] = ui.button(user['name'], on_click=lambda e, user=user: set_userto(user['id'])) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
falkoschindler
-
|
Thanks! Anyhow... now it throws me this exception when the on_click is triggered (creation of the buttons still works fine): |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to capture the value of users at the time each button is created: