Revise input_select list during run

I am trying to create a dashboard, where the input is a class, and some properties of this class is being updated by user. This class for example initialized without any "scenario" and then user adds several scenarios.
At some point, I want the user be able to select one of the created scenarios from drop-down menu.

I have simulated the situation here. I have a list X that has two items ['math','physics']. But by running the dashboard, one element is added to the list as 'chemistry' . However the "ui.input_selec" doesn't follow this, and only show the ['math','physics'].

from shiny import App, ui, render, reactive

X = ["math","physics"]

app_ui = ui.page_fluid(
             ui.navset_card_tab(
                ui.nav("P1",
                       ui.input_select("course",'Select A course', X ),
                       ui.output_text_verbatim("print_list"))))

def server(input, output, session):

    def append_list():
        print("adding item to the list")
        X.append("chemistry")
        print(X)
    
    @output
    @render.text
    def print_list():
        append_list()
        return X

app = App(app_ui, server)

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.