Replies: 1 comment
-
I've tried a few more experiments. If you put a ui element inside a python object, even if Marimo knows about the python object, the ui reactivity does not work. This is a bit of a lurking footgun. Is there a right way to do keep a UI element in another object? Aka, is there a way to say "hey marimo, this object has some ui elements init... pay attention!!" In the below example I display a dropdown, and try to display it's value, but the value display is not updated when the dropdown selection is changed. import marimo
__generated_with = "0.8.0"
app = marimo.App(width="medium")
@app.cell
def __():
import marimo as mo
from dataclasses import dataclass
import typing
return dataclass, mo, typing
@app.cell
def __(dataclass, mo, typing):
@dataclass
class A:
dropdown: typing.Any
dropdown_in_class = A(mo.ui.dropdown(["a","b","c"]))
return A, dropdown_in_class
@app.cell
def __(dropdown_in_class, mo):
mo.vstack([dropdown_in_class.dropdown,
mo.md(f"the value is {dropdown_in_class.dropdown.value}")])
return
if __name__ == "__main__":
app.run() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to have some objects have a method like
.moplot()
that brings up a ui with dropdowns for choices of what to plot, then shows a plot. It's straightforward to to this with two functions called in two cells, one that returns the dropdown, and one the takes the dropdown. But to make it really easy for the user, I'd rather do it with one function? Is there a way to do that? It seems like it's contrary to how the dataflow is used to create reactive uis, but also it would be way easier for users to remember how to call it.Here is a gist with my two function/two cell version: https://gist.github.com/ggggggggg/54defca2d759b895faaf4c7185cc70c4
Beta Was this translation helpful? Give feedback.
All reactions