admin管理员组

文章数量:1122832

I have a Shiny for Python app that uses ui.input_file() and ui.download_button(). For most of the UI Inputs there exists a corresponding ui.update_...() with that you can activate/deactivate a button (ui.update_action_button(id="some_id", disabled=False) or simply undo and made input (ui.update_text("some_other_id", value='')).

Is there a way to clear the selected file in an ui.input_file() input or to enable disable an ui.download_button? I know these are two questions, but they are so closely related that I didn't want to make this two questions.

I have a Shiny for Python app that uses ui.input_file() and ui.download_button(). For most of the UI Inputs there exists a corresponding ui.update_...() with that you can activate/deactivate a button (ui.update_action_button(id="some_id", disabled=False) or simply undo and made input (ui.update_text("some_other_id", value='')).

Is there a way to clear the selected file in an ui.input_file() input or to enable disable an ui.download_button? I know these are two questions, but they are so closely related that I didn't want to make this two questions.

Share Improve this question edited Nov 22, 2024 at 9:01 gernophil asked Nov 21, 2024 at 18:26 gernophilgernophil 4955 silver badges18 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

For the file input, generate it in the server and then you can reset it when you like:

from shiny import App, render, ui, reactive

app_ui = ui.page_fluid(
    ui.input_action_button("reset_input", "Reset Input"),
    ui.output_ui("dynamic_input"),
)

def server(input, output, session):
    
    @output
    @render.ui
    def dynamic_input():
        input.reset_input()
        return ui.input_file("file1", "Choose a file")
    
app = App(app_ui, server)

There should in theory be several ways to disable a download button, but I can't get anything to work.

本文标签: Is there an uiupdateinputfile and uiupdatedownloadbutton in Shiny for PythonStack Overflow