input_selectize in render.ui incompatible with shinywidgets in python

Hello,
I am working on a shiny for python app that uses ui.input_selectize. However, I hit issues when I started to use that in combination with shinywidgets.

If the both the input_selectize and the widget are in the code, the widget will not show the graph and the selectize input will display in a different format than normal (identical to how input_select looks). Here is reproducible code of this as well as what it looks like in the app. I am using shiny 0.6.0, plotly 5.18.0, and shinywidgets 0.2.2

from shiny import ui, App,render
from shinywidgets import output_widget, render_widget
import plotly.express as px

df = px.data.tips()

app_ui = ui.page_fluid(
    ui.output_ui("PN_Selection"),
    ui.div(
        ui.input_select(
            "x", label="Variable",
            choices=["total_bill", "tip", "size"]
        ),
        ui.input_select(
            "color", label="Color",
            choices=["smoker", "sex", "day", "time"]
        ),
        class_="d-flex gap-3"
    ),
    output_widget("my_widget")
)

def server(input, output, session):
       
    @output
    @render_widget
    def my_widget():
        fig = px.histogram(
            df, x=input.x(), color=input.color(),
            marginal="rug"
        )
        fig.layout.height = 275
        return fig
    
    @output
    @render.ui
    def PN_Selection():
      pn_pick=["test","test2","test3"]
      return(ui.TagList(
      ui.input_selectize("PN_Select",label="Select Part Series",choices=dict(zip(pn_pick,pn_pick)),selected="test",multiple=True)
      ))

    

app = App(app_ui, server)

If I comment out "output_widget(my_widget)" the selectize input starts to display correctly, but of course I now have no graph.
image

It also works if you move the input_selectize out of the render.ui and into the main ui section, but unfortunately in my real app, the select input fields are dynamic and need to be part of a render.ui rather than hardcoded in the ui section.

If I change ui.input_selectize to ui.input_select, both the graph and input display ok, so this is my current way around this, however, I prefer the way the selectize input looks for selecting multiple items so I would prefer to use that.

Any idea why selectize input and shinywidget don't seem to mesh well together in this context? Thanks!

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.