Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support panel widgets #82

Open
cpsievert opened this issue Mar 28, 2023 · 0 comments
Open

Support panel widgets #82

cpsievert opened this issue Mar 28, 2023 · 0 comments

Comments

@cpsievert
Copy link
Collaborator

cpsievert commented Mar 28, 2023

Since panel widgets are just bokeh widgets under-the-hood, it seems like it should be possible to support them (an obvious big win for this support would be the Tabulator widget)

We can get most of the way there with the code below, but it's still not clear to me how to properly load Tabulator JS/CSS assets (this is most likely a problem for any bokeh widget "extension" that loads 3rd party JS/CSS).

Here are some relevant threads/PRs that may help with the JS errors that this example generates

holoviz/panel#1525
holoviz/panel#1690

import datetime as dt

import pandas as pd
import panel as pn
from jupyter_bokeh import BokehModel
from shiny import App, ui

from shinywidgets import output_widget, render_widget, bokeh_dependency

app_ui = ui.page_fluid(
    bokeh_dependency(),
    output_widget("my_widget"),
)


def server(input, output, session):
    @output
    @render_widget
    def my_widget():

        df = pd.DataFrame(
            {
                "int": [1, 2, 3],
                "float": [3.14, 6.28, 9.42],
                "str": ["A", "B", "C"],
                "bool": [True, False, True],
                "date": [
                    dt.date(2019, 1, 1),
                    dt.date(2020, 1, 1),
                    dt.date(2020, 1, 10),
                ],
                "datetime": [
                    dt.datetime(2019, 1, 1, 10),
                    dt.datetime(2020, 1, 1, 12),
                    dt.datetime(2020, 1, 10, 13),
                ],
            },
            index=[1, 2, 3],
        )

        w = pn.widgets.Tabulator(df)

        m = BokehModel(w.get_root())

        # TODO: how should Tabulator get loaded?
        print(m._model_module)
        print(m._model_module_version)

        return m


app = App(app_ui, server)
This was referenced Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant