What is the least-bad way to create *reusable* interactive UI elements? #8108
Unanswered
AwdeDarkar
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am a huge fan of marimo and I love its reactive UIs but having to make everything global has become a pretty big pain point. A common pattern for me is to create data classes with rich UI visualizations, for example
This is helpful, the
jsonwidget handles (most) dictionaries I throw at it gracefully with collapsible sub-menus and everything. But suppose the tables are getting too big and nested to navigate easily and I want to be able to filter the display based on a dropdown. Something like,Now it raises a
RuntimeError. My understanding is this happens because marimo's reactivity model relies on tracking changes in global variables to update UI elements. All of the 'state' here is self-contained, no other values can depend onselection, but there doesn't seem to be a way for marimo to respond to this sort of change.Frustratingly, even using
mo.stateand the dropdown'son_changeargument doesn't work. It no longer raises an exception but the changes are never reflected in the UI. I don't know if this is because the getter call isn't correctly forcing a UI update when state changes, or ifon_changeisn't being called in the first place but either way it didn't function as I expended.Is there any way to make this work? The only approach I've found is using AnyWidget but that throws out all the marimo UI widgets and writing javascript in python strings is painful.
Beta Was this translation helpful? Give feedback.
All reactions