machow / reactable-py

https://machow.github.io/reactable-py/
12 stars 1 forks source link

Implement shiny integrations #16

Open machow opened 3 weeks ago

machow commented 3 weeks ago

reactable for R has shiny integrations that let you update a table output reactively. We should be able to wire into py-shiny to do something similar. This might me we provide render, update, and output functions for use with shiny.

https://glin.github.io/reactable/reference/updateReactable.html

See also these issues related to how the widget is wired (which might help as we dig into the widget internals):

machow commented 1 week ago

This is being evaluated as part of https://github.com/posit-dev/py-shiny/issues/1639

machow commented 1 week ago

from chatting w/ @schloerke RE this py-shiny reactable exploration spike, evaluating:

1.  Wire up basic reactivity (simple)
2. Make reactable-py editable (complex)
  * research: what would it take to make reactable.js editable?
  * would involve submitting a PR to glin/reactable
3. Auto data types -> reactable column

It sounds like...

thohan88 commented 21 hours ago

Great to see this being ported to python! Should reactable-py work with shiny in the current version?

I attempted:

from shiny import App, reactive, render, req, ui
from shinywidgets import render_widget, output_widget

app_ui = ui.page_fluid(
    output_widget("tbl"),
)

def server(input, output, session):
    @output
    @render_widget
    def tbl():
        from reactable.data import cars_93
        from reactable.models import Reactable
        react = Reactable(data=cars_93)
        return react.to_widget()

app = App(app_ui, server)

This returns: image

INFO:     Uvicorn running on http://127.0.0.1:1410 (Press CTRL+C to quit)
INFO:     Started reloader process [19884] using WatchFiles
INFO:     Started server process [19886]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     127.0.0.1:62092 - "GET / HTTP/1.1" 200 OK
INFO:     ('127.0.0.1', 62097) - "WebSocket /websocket/" [accepted]
INFO:     connection open
INFO:     127.0.0.1:62092 - "GET /%40widgetti/jupyter-react.js HTTP/1.1" 404 Not Found

I could not find the reference to @widgetti/jupyter-react.js anywhere.

machow commented 17 hours ago

I've explored a bit, and with some tweaking was able to get the js loaded, but wasn't able to get the widget to render. I noticed that simple ipyreact Widgets also don't render, so opened an issue on py-shinywidgets:

https://github.com/posit-dev/py-shinywidgets/issues/160