Skip to content

Can a ui.input value be bound to a list element? #4147

Answered by ed2050
flintcreek asked this question in Q&A
Discussion options

You must be logged in to vote

I don't think it's possible directly. bind_value_to needs a reference to bind to, given as object ref and property name (string). When updating value, it does something like object.setattr (name, newvalue) internally. I'm not aware of a way to access list items by a string name - that's what a dict does.

You could whip up a convoluted solution using a custom helper class or a UserList that takes a key name and gets / sets a specified item in the list. But not a good idea. At that point you're just reinventing a dict poorly.

Can you change your data structure to be a dict instead of a list? That would be a cleaner solution.

If not, perhaps you can change your list to an index. Instead of m…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@flintcreek
Comment options

@ed2050
Comment options

Answer selected by flintcreek
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants