ui.update_date_range
ui.update_date_range(id,
*,
=None,
label=None,
start=None,
endmin=None,
max=None,
=None,
session )
Change the start and end values of a date range input on the client.
Parameters
id : str
-
An input id.
label : Optional[str] = None
-
An input label.
start : Optional[date | str] = None
-
The initial start date. Either a
date
object, or a string in yyyy-mm-dd format. IfNone
(the default), will use the current date in the client’s time zone. end : Optional[date | str] = None
-
The initial end date. Either a
date
object, or a string in yyyy-mm-dd format. IfNone
(the default), will use the current date in the client’s time zone. min : Optional[date | str] = None
-
The minimum allowed value.
max : Optional[date | str] = None
-
The maximum allowed value.
session : Optional[
Session
] = None-
A
Session
instance. If not provided, it is inferred viaget_current_session
.
Note
The input updater functions send a message to the client, telling it to change the settings of an input object. The messages are collected and sent after all the observers (including outputs) have finished running.
The syntax of these functions is similar to the functions that created the inputs in the first place. For example, input_numeric
and update_numeric
take a similar set of arguments.
Any arguments with None
values will be ignored; they will not result in any changes to the input object on the client.
For update_radio_buttons
, update_checkbox_group
, and update_select
, the set of choices can be cleared by using choices=[]
. Similarly, for these inputs, the selected item can be cleared by using selected=[]
.
See Also
Examples
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from datetime import date, timedelta
from shiny import App, Inputs, Outputs, Session, reactive, ui
app_ui = ui.page_fluid(
ui.input_slider("n", "Day of month", min=1, max=30, value=10),
ui.input_date_range("inDateRange", "Input date"),
)
def server(input: Inputs, output: Outputs, session: Session):
@reactive.effect
def _():
d = date(2013, 4, input.n())
ui.update_date_range(
"inDateRange",
label="Date range label " + str(input.n()),
start=d - timedelta(days=1),
end=d + timedelta(days=1),
min=d - timedelta(days=5),
max=d + timedelta(days=5),
)
app = App(app_ui, server)