Render input.select() choices based on input file using PyShiny (Express)

Hi!

I am building an application where the user chooses something from input.select().
The choices in this component depend on the input file uploaded. I have function that is passing a list of choices to the component.

I have gone through [Shiny for Python - Dynamic UI Shiny for Python - Express in depth (posit.co) and Shiny for Python - Express in depth (posit.co). I tried to use @render.express but it doesn't seem to render the ui.

Here's what my code looks like:

with ui.nav_panel("Force Per Joint"):
    with ui.layout_sidebar():
      with ui.sidebar(id='case_options', width=350):
        with ui.accordion(open=True):
          with ui.accordion_panel(title="output_case"):
            ui.input_selectize(id = "outputCases", label="outputCasesLabel", choices = [])
            
            @reactive.effect
            def getOutputCaseOptions():
              file: list[FileInfo] | None = input.file1()
              if file is not None:
                outputCaseOptions = getOutputCases()
                ui.update_selectize(id = "outputCases", choices = outputCaseOptions)

      with ui.navset_card_tab(id="force_choices"):  
        with ui.nav_panel("Plots 📈"):
          with ui.layout_columns():
            with ui.card(full_screen=True):
             "Something"

Could someone help me with the way ahead?
Thanks!

I found out my mistake or rather overlooked the most basic thing:
My function getOutputCases() wasn't returning anything for the chosen dataset, so it wasn't getting updated.

But the decorator is correct - in case, this helps anyone in the future.
Cheers

This topic was automatically closed 7 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.