Trouble updating options in a multiselect
I'm trying to update the options in a multiselect, but it's not working, and I'm not sure if what I'm doing is incorrect, or if marimo just doesnt work the same way as my brain. I've got a dataframe and im making two multiselects based on the values in the dataframe. if the user chooses a value from the first multiselect, i want to filter the options in the second with the values based on the selected option. my callback that I wrote for the first multiselect to update the options in the second is properly filtering the dataframe and finding the new values, but the second multiselect always shows all the possible options.
I've tried all sorts of things to get it to work, including moving stuff to other cells, but that kept causing cyclical dependency errors. In the end I'm wanting to make a few different multiselects and then do other stuff with the filtered dataframe. I was hoping someone around here would be able to provide some insight. thanks! here's my non working code 😦
I've tried all sorts of things to get it to work, including moving stuff to other cells, but that kept causing cyclical dependency errors. In the end I'm wanting to make a few different multiselects and then do other stuff with the filtered dataframe. I was hoping someone around here would be able to provide some insight. thanks! here's my non working code 😦
4 Replies
Someone will reply to you shortly. In the meantime, this might help:
Hi! One of marimo’s biggest rules is to avoid using callbacks. Can you try reading this: https://docs.marimo.io/guides/interactivity/
Interactive elements - marimo
The next generation of Python notebooks
Also here are a bunch of examples: https://github.com/marimo-team/marimo/tree/main/examples/ui
GitHub
marimo/examples/ui at main · marimo-team/marimo
A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git. - marimo-team/marimo
In particular don’t use the on_change method