From 915a425e73eeaab7363f190912d043840e26d4b3 Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Wed, 24 Jan 2024 14:25:58 -0400 Subject: [PATCH 1/4] expressify-input-examples input_checkbox input_checkbox_group input_date input_file input_numeric input_pasword input_radio_buttons input_select input_selectize input_slider input_switch input_text input_text_area --- .../input_action_link/app-express.py | 20 ++++++++ .../input_checkbox/app-express.py | 8 ++++ .../input_checkbox_group/app-express.py | 18 +++++++ shiny/api-examples/input_date/app-express.py | 24 ++++++++++ shiny/api-examples/input_file/app-express.py | 48 +++++++++++++++++++ .../api-examples/input_numeric/app-express.py | 8 ++++ .../input_password/app-express.py | 11 +++++ .../input_radio_buttons/app-express.py | 15 ++++++ .../api-examples/input_select/app-express.py | 16 +++++++ .../input_selectize/app-express.py | 45 +++++++++++++++++ shiny/api-examples/input_selectize/app.py | 4 +- .../api-examples/input_slider/app-express.py | 16 +++++++ .../api-examples/input_switch/app-express.py | 8 ++++ shiny/api-examples/input_switch/app.py | 4 +- shiny/api-examples/input_text/app-express.py | 8 ++++ .../input_text_area/app-express.py | 25 ++++++++++ 16 files changed, 274 insertions(+), 4 deletions(-) create mode 100644 shiny/api-examples/input_action_link/app-express.py create mode 100644 shiny/api-examples/input_checkbox/app-express.py create mode 100644 shiny/api-examples/input_checkbox_group/app-express.py create mode 100644 shiny/api-examples/input_date/app-express.py create mode 100644 shiny/api-examples/input_file/app-express.py create mode 100644 shiny/api-examples/input_numeric/app-express.py create mode 100644 shiny/api-examples/input_password/app-express.py create mode 100644 shiny/api-examples/input_radio_buttons/app-express.py create mode 100644 shiny/api-examples/input_select/app-express.py create mode 100644 shiny/api-examples/input_selectize/app-express.py create mode 100644 shiny/api-examples/input_slider/app-express.py create mode 100644 shiny/api-examples/input_switch/app-express.py create mode 100644 shiny/api-examples/input_text/app-express.py create mode 100644 shiny/api-examples/input_text_area/app-express.py diff --git a/shiny/api-examples/input_action_link/app-express.py b/shiny/api-examples/input_action_link/app-express.py new file mode 100644 index 000000000..eec5faafa --- /dev/null +++ b/shiny/api-examples/input_action_link/app-express.py @@ -0,0 +1,20 @@ +import matplotlib.pyplot as plt +import numpy as np + +from shiny import reactive +from shiny.express import input, render, ui + +ui.input_slider("n", "Number of observations", min=0, max=1000, value=500), +ui.input_action_link("go", "Go!"), + + +@render.plot(alt="A histogram") +# reactive.event() to invalidate the plot when the button is pressed but not when +# the slider is changed +@reactive.event(input.go, ignore_none=False) +def plot(): + np.random.seed(19680801) + x = 100 + 15 * np.random.randn(input.n()) + fig, ax = plt.subplots() + ax.hist(x, bins=30, density=True) + return fig diff --git a/shiny/api-examples/input_checkbox/app-express.py b/shiny/api-examples/input_checkbox/app-express.py new file mode 100644 index 000000000..7fbbfc50a --- /dev/null +++ b/shiny/api-examples/input_checkbox/app-express.py @@ -0,0 +1,8 @@ +from shiny.express import input, render, ui + +ui.input_checkbox("somevalue", "Some value", False), + + +@render.ui +def value(): + return input.somevalue() diff --git a/shiny/api-examples/input_checkbox_group/app-express.py b/shiny/api-examples/input_checkbox_group/app-express.py new file mode 100644 index 000000000..9f3b9652b --- /dev/null +++ b/shiny/api-examples/input_checkbox_group/app-express.py @@ -0,0 +1,18 @@ +from shiny import req +from shiny.express import input, render, ui + +ui.input_checkbox_group( + "colors", + "Choose color(s):", + { + "red": ui.span("Red", style="color: #FF0000;"), + "green": ui.span("Green", style="color: #00AA00;"), + "blue": ui.span("Blue", style="color: #0000AA;"), + }, +) + + +@render.ui +def val(): + req(input.colors()) + return "You chose " + ", ".join(input.colors()) diff --git a/shiny/api-examples/input_date/app-express.py b/shiny/api-examples/input_date/app-express.py new file mode 100644 index 000000000..535cbea18 --- /dev/null +++ b/shiny/api-examples/input_date/app-express.py @@ -0,0 +1,24 @@ +from datetime import date + +from shiny.express import ui + +ui.input_date("date1", "Date:", value="2016-02-29"), +# Default value is the date in client's time zone +ui.input_date("date2", "Date:"), +# value is always yyyy-mm-dd, even if the display format is different +ui.input_date("date3", "Date:", value="2016-02-29", format="mm/dd/yy"), +# Pass in a Date object +ui.input_date("date4", "Date:", value=date(2016, 2, 29)), +# Use different language and different first day of week +ui.input_date("date5", "Date:", language="ru", weekstart=1), +# Start with decade view instead of default month view +ui.input_date("date6", "Date:", startview="decade"), +# Disable Mondays and Tuesdays. +ui.input_date("date7", "Date:", daysofweekdisabled=[1, 2]), +# Disable specific dates. +ui.input_date( + "date8", + "Date:", + value="2016-02-29", + datesdisabled=["2016-03-01", "2016-03-02"], +), diff --git a/shiny/api-examples/input_file/app-express.py b/shiny/api-examples/input_file/app-express.py new file mode 100644 index 000000000..81222e4f7 --- /dev/null +++ b/shiny/api-examples/input_file/app-express.py @@ -0,0 +1,48 @@ +import pandas as pd + +from shiny import reactive +from shiny.express import input, render, ui +from shiny.types import FileInfo + +ui.input_file("file1", "Choose CSV File", accept=[".csv"], multiple=False) +ui.input_checkbox_group( + "stats", + "Summary Stats", + choices=["Row Count", "Column Count", "Column Names"], + selected=["Row Count", "Column Count", "Column Names"], +) + + +@reactive.Calc +def parsed_file(): + file: list[FileInfo] | None = input.file1() + if file is None: + return pd.DataFrame() + return pd.read_csv(file[0]["datapath"]) # pyright: ignore[reportUnknownMemberType] + + +@render.table +def summary(): + df = parsed_file() + + if df.empty: + return pd.DataFrame() + + # Get the row count, column count, and column names of the DataFrame + row_count = df.shape[0] + column_count = df.shape[1] + names = df.columns.tolist() + column_names = ", ".join(str(name) for name in names) + + # Create a new DataFrame to display the information + info_df = pd.DataFrame( + { + "Row Count": [row_count], + "Column Count": [column_count], + "Column Names": [column_names], + } + ) + + # input.stats() is a list of strings; subset the columns based on the selected + # checkboxes + return info_df.loc[:, input.stats()] diff --git a/shiny/api-examples/input_numeric/app-express.py b/shiny/api-examples/input_numeric/app-express.py new file mode 100644 index 000000000..7e06f1c0a --- /dev/null +++ b/shiny/api-examples/input_numeric/app-express.py @@ -0,0 +1,8 @@ +from shiny.express import input, render, ui + +ui.input_numeric("obs", "Observations:", 10, min=1, max=100) + + +@render.code +def value(): + return input.obs() diff --git a/shiny/api-examples/input_password/app-express.py b/shiny/api-examples/input_password/app-express.py new file mode 100644 index 000000000..4366c5303 --- /dev/null +++ b/shiny/api-examples/input_password/app-express.py @@ -0,0 +1,11 @@ +from shiny import reactive +from shiny.express import input, render, ui + +ui.input_password("password", "Password:") +ui.input_action_button("go", "Go") + + +@render.code +@reactive.event(input.go) +def value(): + return input.password() diff --git a/shiny/api-examples/input_radio_buttons/app-express.py b/shiny/api-examples/input_radio_buttons/app-express.py new file mode 100644 index 000000000..5354f4134 --- /dev/null +++ b/shiny/api-examples/input_radio_buttons/app-express.py @@ -0,0 +1,15 @@ +from shiny.express import input, render, ui + +ui.input_radio_buttons( + "rb", + "Choose one:", + { + "html": ui.HTML("Red Text"), + "text": "Normal text", + }, +) + + +@render.express +def val(): + "You chose " + input.rb() diff --git a/shiny/api-examples/input_select/app-express.py b/shiny/api-examples/input_select/app-express.py new file mode 100644 index 000000000..c45482f0c --- /dev/null +++ b/shiny/api-examples/input_select/app-express.py @@ -0,0 +1,16 @@ +from shiny.express import input, render, ui + +ui.input_select( + "state", + "Choose a state:", + { + "East Coast": {"NY": "New York", "NJ": "New Jersey", "CT": "Connecticut"}, + "West Coast": {"WA": "Washington", "OR": "Oregon", "CA": "California"}, + "Midwest": {"MN": "Minnesota", "WI": "Wisconsin", "IA": "Iowa"}, + }, +) + + +@render.text +def value(): + return "You choose: " + str(input.state()) diff --git a/shiny/api-examples/input_selectize/app-express.py b/shiny/api-examples/input_selectize/app-express.py new file mode 100644 index 000000000..d58e04154 --- /dev/null +++ b/shiny/api-examples/input_selectize/app-express.py @@ -0,0 +1,45 @@ +from html import escape # noqa: F401 + +from shiny.express import input, render, ui + +states = { + "East Coast": {"NY": "New York", "NJ": "New Jersey", "CT": "Connecticut"}, + "West Coast": {"WA": "Washington", "OR": "Oregon", "CA": "California"}, + "Midwest": {"MN": "Minnesota", "WI": "Wisconsin", "IA": "Iowa"}, +} + +ui.input_selectize( + "state", + "Choose a state:", + states, + multiple=True, +) + + +@render.text +def value(): + return "You choose: " + str(input.state()) + + +ui.input_selectize( + "state2", + "Selectize Options", + states, + multiple=True, + options=( + { + "placeholder": "Enter text", + "render": ui.js_eval( + '{option: function(item, escape) {return "
Select " + escape(item.label) + "
";}}' + ), + "create": True, + } + ), +) +ui.input_selectize( + "state3", + "Selectize plugins", + states, + multiple=True, + options={"plugins": ["clear_button"]}, +) diff --git a/shiny/api-examples/input_selectize/app.py b/shiny/api-examples/input_selectize/app.py index bc2dd9bd9..23a63d376 100644 --- a/shiny/api-examples/input_selectize/app.py +++ b/shiny/api-examples/input_selectize/app.py @@ -17,7 +17,7 @@ ), ui.output_text("value"), ui.input_selectize( - "state", + "state2", "Selectize Options", states, multiple=True, @@ -32,7 +32,7 @@ ), ), ui.input_selectize( - "state", + "state3", "Selectize plugins", states, multiple=True, diff --git a/shiny/api-examples/input_slider/app-express.py b/shiny/api-examples/input_slider/app-express.py new file mode 100644 index 000000000..fd4bb540f --- /dev/null +++ b/shiny/api-examples/input_slider/app-express.py @@ -0,0 +1,16 @@ +import matplotlib.pyplot as plt +import numpy as np + +from shiny.express import input, render, ui + +ui.input_slider("obs", "Number of bins:", min=10, max=100, value=30), + + +@render.plot +def distPlot(): + np.random.seed(19680801) + x = 100 + 15 * np.random.randn(437) + + fig, ax = plt.subplots() + ax.hist(x, input.obs(), density=True) + return fig diff --git a/shiny/api-examples/input_switch/app-express.py b/shiny/api-examples/input_switch/app-express.py new file mode 100644 index 000000000..2a15d9e2a --- /dev/null +++ b/shiny/api-examples/input_switch/app-express.py @@ -0,0 +1,8 @@ +from shiny.express import input, render, ui + +ui.input_switch("somevalue", "Some value", False), + + +@render.text +def value(): + return input.somevalue() diff --git a/shiny/api-examples/input_switch/app.py b/shiny/api-examples/input_switch/app.py index a438d8195..f05cba431 100644 --- a/shiny/api-examples/input_switch/app.py +++ b/shiny/api-examples/input_switch/app.py @@ -2,12 +2,12 @@ app_ui = ui.page_fluid( ui.input_switch("somevalue", "Some value", False), - ui.output_ui("value"), + ui.output_text("value"), ) def server(input: Inputs, output: Outputs, session: Session): - @render.ui + @render.text def value(): return input.somevalue() diff --git a/shiny/api-examples/input_text/app-express.py b/shiny/api-examples/input_text/app-express.py new file mode 100644 index 000000000..f5450e682 --- /dev/null +++ b/shiny/api-examples/input_text/app-express.py @@ -0,0 +1,8 @@ +from shiny.express import input, render, ui + +ui.input_text("caption", "Caption:", "Data summary"), + + +@render.code +def value(): + return input.caption() diff --git a/shiny/api-examples/input_text_area/app-express.py b/shiny/api-examples/input_text_area/app-express.py new file mode 100644 index 000000000..4841f56ee --- /dev/null +++ b/shiny/api-examples/input_text_area/app-express.py @@ -0,0 +1,25 @@ +from shiny.express import input, render, ui + +ui.input_text_area( + "caption_regular", + "Caption:", + "Data summary\nwith\nmultiple\nlines", +) + + +@render.text +def value_regular(): + return input.caption_regular() + + +ui.input_text_area( + "caption_autoresize", + ui.markdown("Caption (w/ `autoresize=True`):"), + "Data summary\nwith\nmultiple\nlines", + autoresize=True, +) + + +@render.text +def value_autoresize(): + return input.caption_autoresize() From f783409fca6d0b506cd3714da74aa58dc37704ee Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Wed, 24 Jan 2024 14:36:52 -0400 Subject: [PATCH 2/4] Remove trailing commas --- .../input_action_link/app-express.py | 4 +- .../input_checkbox/app-express.py | 2 +- shiny/api-examples/input_date/app-express.py | 14 ++--- .../input_date_range/app-express.py | 38 +++++++++++++ shiny/api-examples/input_date_range/app.py | 57 ++++++++----------- 5 files changed, 71 insertions(+), 44 deletions(-) create mode 100644 shiny/api-examples/input_date_range/app-express.py diff --git a/shiny/api-examples/input_action_link/app-express.py b/shiny/api-examples/input_action_link/app-express.py index eec5faafa..39939d756 100644 --- a/shiny/api-examples/input_action_link/app-express.py +++ b/shiny/api-examples/input_action_link/app-express.py @@ -4,8 +4,8 @@ from shiny import reactive from shiny.express import input, render, ui -ui.input_slider("n", "Number of observations", min=0, max=1000, value=500), -ui.input_action_link("go", "Go!"), +ui.input_slider("n", "Number of observations", min=0, max=1000, value=500) +ui.input_action_link("go", "Go!") @render.plot(alt="A histogram") diff --git a/shiny/api-examples/input_checkbox/app-express.py b/shiny/api-examples/input_checkbox/app-express.py index 7fbbfc50a..1c7e87f7e 100644 --- a/shiny/api-examples/input_checkbox/app-express.py +++ b/shiny/api-examples/input_checkbox/app-express.py @@ -1,6 +1,6 @@ from shiny.express import input, render, ui -ui.input_checkbox("somevalue", "Some value", False), +ui.input_checkbox("somevalue", "Some value", False) @render.ui diff --git a/shiny/api-examples/input_date/app-express.py b/shiny/api-examples/input_date/app-express.py index 535cbea18..41abe3569 100644 --- a/shiny/api-examples/input_date/app-express.py +++ b/shiny/api-examples/input_date/app-express.py @@ -2,19 +2,19 @@ from shiny.express import ui -ui.input_date("date1", "Date:", value="2016-02-29"), +ui.input_date("date1", "Date:", value="2016-02-29") # Default value is the date in client's time zone -ui.input_date("date2", "Date:"), +ui.input_date("date2", "Date:") # value is always yyyy-mm-dd, even if the display format is different -ui.input_date("date3", "Date:", value="2016-02-29", format="mm/dd/yy"), +ui.input_date("date3", "Date:", value="2016-02-29", format="mm/dd/yy") # Pass in a Date object -ui.input_date("date4", "Date:", value=date(2016, 2, 29)), +ui.input_date("date4", "Date:", value=date(2016, 2, 29)) # Use different language and different first day of week -ui.input_date("date5", "Date:", language="ru", weekstart=1), +ui.input_date("date5", "Date:", language="ru", weekstart=1) # Start with decade view instead of default month view -ui.input_date("date6", "Date:", startview="decade"), +ui.input_date("date6", "Date:", startview="decade") # Disable Mondays and Tuesdays. -ui.input_date("date7", "Date:", daysofweekdisabled=[1, 2]), +ui.input_date("date7", "Date:", daysofweekdisabled=[1, 2]) # Disable specific dates. ui.input_date( "date8", diff --git a/shiny/api-examples/input_date_range/app-express.py b/shiny/api-examples/input_date_range/app-express.py new file mode 100644 index 000000000..07b4bcbac --- /dev/null +++ b/shiny/api-examples/input_date_range/app-express.py @@ -0,0 +1,38 @@ +from datetime import date + +from shiny import App, Inputs, Outputs, Session, ui + +app_ui = ui.page_fluid( + ui.input_date_range( + "daterange1", "Date range:", start="2001-01-01", end="2010-12-31" + ), + # Default start and end is the current date in the client's time zone + ui.input_date_range("daterange2", "Date range:"), + # start and end are always specified in yyyy-mm-dd, even if the display + # format is different + ui.input_date_range( + "daterange3", + "Date range:", + start="2001-01-01", + end="2010-12-31", + min="2001-01-01", + max="2012-12-21", + format="mm/dd/yy", + separator=" - ", + ), + # Pass in Date objects + ui.input_date_range( + "daterange4", "Date range:", start=date(2001, 1, 1), end=date(2010, 12, 31) + ), + # Use different language and different first day of week + ui.input_date_range("daterange5", "Date range:", language="de", weekstart=1), + # Start with decade view instead of default month view + ui.input_date_range("daterange6", "Date range:", startview="decade"), +) + + +def server(input: Inputs, output: Outputs, session: Session): + pass + + +app = App(app_ui, server) diff --git a/shiny/api-examples/input_date_range/app.py b/shiny/api-examples/input_date_range/app.py index 07b4bcbac..fe39327b1 100644 --- a/shiny/api-examples/input_date_range/app.py +++ b/shiny/api-examples/input_date_range/app.py @@ -1,38 +1,27 @@ from datetime import date -from shiny import App, Inputs, Outputs, Session, ui +from shiny.express import input, ui -app_ui = ui.page_fluid( - ui.input_date_range( - "daterange1", "Date range:", start="2001-01-01", end="2010-12-31" - ), - # Default start and end is the current date in the client's time zone - ui.input_date_range("daterange2", "Date range:"), - # start and end are always specified in yyyy-mm-dd, even if the display - # format is different - ui.input_date_range( - "daterange3", - "Date range:", - start="2001-01-01", - end="2010-12-31", - min="2001-01-01", - max="2012-12-21", - format="mm/dd/yy", - separator=" - ", - ), - # Pass in Date objects - ui.input_date_range( - "daterange4", "Date range:", start=date(2001, 1, 1), end=date(2010, 12, 31) - ), - # Use different language and different first day of week - ui.input_date_range("daterange5", "Date range:", language="de", weekstart=1), - # Start with decade view instead of default month view - ui.input_date_range("daterange6", "Date range:", startview="decade"), +ui.input_date_range("daterange1", "Date range:", start="2001-01-01", end="2010-12-31") +# Default start and end is the current date in the client's time zone +ui.input_date_range("daterange2", "Date range:") +# start and end are always specified in yyyy-mm-dd, even if the display +# format is different +ui.input_date_range( + "daterange3", + "Date range:", + start="2001-01-01", + end="2010-12-31", + min="2001-01-01", + max="2012-12-21", + format="mm/dd/yy", + separator=" - ", ) - - -def server(input: Inputs, output: Outputs, session: Session): - pass - - -app = App(app_ui, server) +# Pass in Date objects +ui.input_date_range( + "daterange4", "Date range:", start=date(2001, 1, 1), end=date(2010, 12, 31) +) +# Use different language and different first day of week +ui.input_date_range("daterange5", "Date range:", language="de", weekstart=1) +# Start with decade view instead of default month view +ui.input_date_range("daterange6", "Date range:", startview="decade") From 65419985d763bb28f5e12151f88b71dd52aed34e Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Wed, 24 Jan 2024 15:35:57 -0400 Subject: [PATCH 3/4] Trailing commas --- shiny/api-examples/input_date/app-express.py | 2 +- .../input_date_range/app-express.py | 57 ++++++++----------- .../api-examples/input_slider/app-express.py | 2 +- .../api-examples/input_switch/app-express.py | 2 +- shiny/api-examples/input_text/app-express.py | 2 +- 5 files changed, 27 insertions(+), 38 deletions(-) diff --git a/shiny/api-examples/input_date/app-express.py b/shiny/api-examples/input_date/app-express.py index 41abe3569..bd696beb3 100644 --- a/shiny/api-examples/input_date/app-express.py +++ b/shiny/api-examples/input_date/app-express.py @@ -21,4 +21,4 @@ "Date:", value="2016-02-29", datesdisabled=["2016-03-01", "2016-03-02"], -), +) diff --git a/shiny/api-examples/input_date_range/app-express.py b/shiny/api-examples/input_date_range/app-express.py index 07b4bcbac..66f79c5c4 100644 --- a/shiny/api-examples/input_date_range/app-express.py +++ b/shiny/api-examples/input_date_range/app-express.py @@ -1,38 +1,27 @@ from datetime import date -from shiny import App, Inputs, Outputs, Session, ui +from shiny.express import ui -app_ui = ui.page_fluid( - ui.input_date_range( - "daterange1", "Date range:", start="2001-01-01", end="2010-12-31" - ), - # Default start and end is the current date in the client's time zone - ui.input_date_range("daterange2", "Date range:"), - # start and end are always specified in yyyy-mm-dd, even if the display - # format is different - ui.input_date_range( - "daterange3", - "Date range:", - start="2001-01-01", - end="2010-12-31", - min="2001-01-01", - max="2012-12-21", - format="mm/dd/yy", - separator=" - ", - ), - # Pass in Date objects - ui.input_date_range( - "daterange4", "Date range:", start=date(2001, 1, 1), end=date(2010, 12, 31) - ), - # Use different language and different first day of week - ui.input_date_range("daterange5", "Date range:", language="de", weekstart=1), - # Start with decade view instead of default month view - ui.input_date_range("daterange6", "Date range:", startview="decade"), +ui.input_date_range("daterange1", "Date range:", start="2001-01-01", end="2010-12-31") +# Default start and end is the current date in the client's time zone +ui.input_date_range("daterange2", "Date range:") +# start and end are always specified in yyyy-mm-dd, even if the display +# format is different +ui.input_date_range( + "daterange3", + "Date range:", + start="2001-01-01", + end="2010-12-31", + min="2001-01-01", + max="2012-12-21", + format="mm/dd/yy", + separator=" - ", ) - - -def server(input: Inputs, output: Outputs, session: Session): - pass - - -app = App(app_ui, server) +# Pass in Date objects +ui.input_date_range( + "daterange4", "Date range:", start=date(2001, 1, 1), end=date(2010, 12, 31) +) +# Use different language and different first day of week +ui.input_date_range("daterange5", "Date range:", language="de", weekstart=1) +# Start with decade view instead of default month view +ui.input_date_range("daterange6", "Date range:", startview="decade") diff --git a/shiny/api-examples/input_slider/app-express.py b/shiny/api-examples/input_slider/app-express.py index fd4bb540f..e6e701594 100644 --- a/shiny/api-examples/input_slider/app-express.py +++ b/shiny/api-examples/input_slider/app-express.py @@ -3,7 +3,7 @@ from shiny.express import input, render, ui -ui.input_slider("obs", "Number of bins:", min=10, max=100, value=30), +ui.input_slider("obs", "Number of bins:", min=10, max=100, value=30) @render.plot diff --git a/shiny/api-examples/input_switch/app-express.py b/shiny/api-examples/input_switch/app-express.py index 2a15d9e2a..efd623850 100644 --- a/shiny/api-examples/input_switch/app-express.py +++ b/shiny/api-examples/input_switch/app-express.py @@ -1,6 +1,6 @@ from shiny.express import input, render, ui -ui.input_switch("somevalue", "Some value", False), +ui.input_switch("somevalue", "Some value", False) @render.text diff --git a/shiny/api-examples/input_text/app-express.py b/shiny/api-examples/input_text/app-express.py index f5450e682..8c0c30d69 100644 --- a/shiny/api-examples/input_text/app-express.py +++ b/shiny/api-examples/input_text/app-express.py @@ -1,6 +1,6 @@ from shiny.express import input, render, ui -ui.input_text("caption", "Caption:", "Data summary"), +ui.input_text("caption", "Caption:", "Data summary") @render.code From 4e25ac7b210893f73b730d16a5076af22b645aad Mon Sep 17 00:00:00 2001 From: Gordon Shotwell Date: Wed, 24 Jan 2024 19:49:09 -0400 Subject: [PATCH 4/4] Linting --- shiny/api-examples/input_date_range/app.py | 57 +++++++++++++--------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/shiny/api-examples/input_date_range/app.py b/shiny/api-examples/input_date_range/app.py index fe39327b1..07b4bcbac 100644 --- a/shiny/api-examples/input_date_range/app.py +++ b/shiny/api-examples/input_date_range/app.py @@ -1,27 +1,38 @@ from datetime import date -from shiny.express import input, ui +from shiny import App, Inputs, Outputs, Session, ui -ui.input_date_range("daterange1", "Date range:", start="2001-01-01", end="2010-12-31") -# Default start and end is the current date in the client's time zone -ui.input_date_range("daterange2", "Date range:") -# start and end are always specified in yyyy-mm-dd, even if the display -# format is different -ui.input_date_range( - "daterange3", - "Date range:", - start="2001-01-01", - end="2010-12-31", - min="2001-01-01", - max="2012-12-21", - format="mm/dd/yy", - separator=" - ", +app_ui = ui.page_fluid( + ui.input_date_range( + "daterange1", "Date range:", start="2001-01-01", end="2010-12-31" + ), + # Default start and end is the current date in the client's time zone + ui.input_date_range("daterange2", "Date range:"), + # start and end are always specified in yyyy-mm-dd, even if the display + # format is different + ui.input_date_range( + "daterange3", + "Date range:", + start="2001-01-01", + end="2010-12-31", + min="2001-01-01", + max="2012-12-21", + format="mm/dd/yy", + separator=" - ", + ), + # Pass in Date objects + ui.input_date_range( + "daterange4", "Date range:", start=date(2001, 1, 1), end=date(2010, 12, 31) + ), + # Use different language and different first day of week + ui.input_date_range("daterange5", "Date range:", language="de", weekstart=1), + # Start with decade view instead of default month view + ui.input_date_range("daterange6", "Date range:", startview="decade"), ) -# Pass in Date objects -ui.input_date_range( - "daterange4", "Date range:", start=date(2001, 1, 1), end=date(2010, 12, 31) -) -# Use different language and different first day of week -ui.input_date_range("daterange5", "Date range:", language="de", weekstart=1) -# Start with decade view instead of default month view -ui.input_date_range("daterange6", "Date range:", startview="decade") + + +def server(input: Inputs, output: Outputs, session: Session): + pass + + +app = App(app_ui, server)