posit-dev / py-shinywidgets

Render ipywidgets inside a PyShiny app
MIT License
46 stars 5 forks source link

pydeck requires deck.update() call to render #51

Closed jcheng5 closed 2 years ago

jcheng5 commented 2 years ago

Description

from shiny import Inputs, Outputs, Session, App, reactive, render, ui
from shinywidgets import output_widget, register_widget
import pydeck as pdk

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

def server(input: Inputs, output: Outputs, session: Session):
    # Render
    deck = pdk.Deck()
    register_widget("deck", deck)
    deck.update()

# The debug=True causes it to print messages to the console.
app = App(app_ui, server, debug=True)

Without the deck.update(), nothing renders.

jcheng5 commented 2 years ago

I tried calling deck.update() before register_widget() and that works, too. And it looks like the Deck object has a show() method that calls update() and then returns .deck_widget. So maybe the _as_widget() should call .show() instead of .deck_widget.