I have recently started working with Shiny Python and got stuck at some point.
from pathlib import Path
from shiny import reactive
from shiny.express import input, render, ui
ui.page_opts(title="Stock explorer", fillable=True)
with ui.sidebar():
ui.input_text("data_one","Insert Number",placeholder="Insert Number 1")
ui.input_text("data_two","Insert Number",placeholder="Insert Number 2")
ui.input_action_button("add_data", "Add Data", class_="btn-primary")
ui.input_action_button("delete_data", "Delete Data", class_= "btn-danger")
with ui.layout_column_wrap(fill=False):
with ui.value_box():
"Number One"
@render.ui
def data_1():
return f"{get_data_one()}"
with ui.value_box():
"Number 2"
@render.ui
def data_2():
return f"{get_data_two()}"
ui.include_css(Path(__file__).parent / "styles.css")
@reactive.calc
@reactive.event(input.add_data, ignore_none=False)
def get_data_one():
return input.data_one()
@reactive.calc
@reactive.event(input.add_data, ignore_none=False)
def get_data_two():
return input.data_two()
@reactive.calc
def data_delete():
pass
I am stuck as to how I can update the ui.value_box as empty while pressing the Delete Data button. In the reference page Shiny for Python I can see I would be able to update inputs and layout, but not able to get how to update the value_box. I have kept the data_delete() function to be pass as of now.
Any feedback or suggestions will help.