Giter Club home page Giter Club logo

Comments (6)

crazycapivara avatar crazycapivara commented on July 23, 2024

Same for using marimo.ui.anywidget.

from marimo.

mscolnick avatar mscolnick commented on July 23, 2024

To bring anywidget into marimo's reactive system, you'll need to wrap it in mo.ui.anywidget

m = MapWidget(map_options)
m.use_message_queue(False)
m.add_control(NavigationControl())
m.add_deck_layers([deck_grid_layer])
map = mo.ui.anywidget(m)
map

In order for the downstream cell's to re-render based off the reactive changes from w, you'll need to pick the values off that instead of m.

map.value["clicked"]

or you can force the dependency between cells by doing something like:

map.widget.clicked

We can look into making anywidget more tightly integrated without having to wrap marimo.ui.anywidget

from marimo.

crazycapivara avatar crazycapivara commented on July 23, 2024

Hi, yes I know and I first did it this way and w.value works fine but I need it the other way round. I need to update the widget itself from Python, e. g. to update layer properties after it was initially rendered. In the example I provided I wanted to add a ScaleControl after the widget was rendered. This is done via Anywidget.send method.

See sending custom messages.

Maybe only model.on("change:my_value") is supported?

from marimo.

mscolnick avatar mscolnick commented on July 23, 2024

Oh sorry - I read this fast and started with your re-production code, which didn't have .send - but i see now, its from add_control(ScaleControl()).

I can look into getting .send working, but this feels like mutating state which usually does not play nicely in a reactive environment.

from marimo.

mscolnick avatar mscolnick commented on July 23, 2024

I can see the value of .send in other contexts (button click or conditionals). We can look into supporting this, but as of now, we don't have any existing mechanism for python widgets to send data to their frontend counterpart after rendering (we do if they request it, as an RPC), but not a plain bi-directional connection.

from marimo.

mscolnick avatar mscolnick commented on July 23, 2024

I have a fix here: #1776

I added a test example to make sure this works. Since the adding the controls are not idempotent (you can add the same control multiple times), i put it behind a mo.ui.run_button()

from marimo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.