202 Reactive Event

Instructions

Add an input.action_button to the app, and use @reactive.event to prevent the text from printing until the user presses the button.

#| standalone: true
#| components: [viewer]
#| layout: horizontal
#| viewerHeight: 800
from shiny.express import ui, render, input
from shiny import reactive

ui.input_text("input_txt", "Enter text")
ui.input_action_button("send", "Enter")
@render.text
@reactive.event(input.send)
def output_txt():
    return input.input_txt()



## file: requirements.txt
plotly
#| standalone: true
#| components: [editor, viewer]
#| layout: horizontal
#| viewerHeight: 800
from shiny.express import ui, render, input
from shiny import reactive

ui.input_text("input_txt", "Enter text")
ui.input_action_button("send", "Enter")
@render.text
@reactive.event(input.send)
def output_txt():
    return input.input_txt()



## file: requirements.txt
plotly