Skip to content

Commit

Permalink
WIP: Shiny Express changes (#94)
Browse files Browse the repository at this point in the history
- Translate applications into express syntax where possible
- Remove examples which have been superceded by Component galleries

---------

Co-authored-by: Garrick Aden-Buie <[email protected]>
Co-authored-by: Winston Chang <[email protected]>
  • Loading branch information
3 people authored Jan 29, 2024
1 parent a941a51 commit 91172d6
Show file tree
Hide file tree
Showing 24 changed files with 694 additions and 1,115 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/venv/
**/.venv/
**/.DS_store/
/node_modules/
/packages/*.whl
/dist/
Expand Down
55 changes: 11 additions & 44 deletions examples/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,21 @@
},
{
"category": "Featured",
"apps": [
"cpuinfo",
"orbit",
"regularization",
"wordle",
"plotly",
"ipyleaflet",
"camera"
]
"apps": ["cpuinfo", "regularization", "plotly", "ipyleaflet"]
},
{
"category": "Intermediate",
"apps": [
"multiple_source_files",
"read_local_csv_file",
"file_upload",
"file_download",
"insert_ui",
"input_update",
"modules",
"extra_packages",
"static_content",
"fetch",
"ipywidgets"
]
},
{
"category": "Inputs",
"apps": [
"input_text",
"input_numeric",
"input_slider",
"input_checkbox",
"input_switch",
"input_checkbox_group",
"input_select",
"input_radio",
"input_text_area",
"input_date",
"input_date_range",
"input_password"
]
},
{
"category": "Outputs",
"apps": [
"output_text",
"output_text_verbatim",
"output_ui",
"output_plot",
"output_table",
"output_data_frame_grid"
]
},
{
"category": "Layout",
"apps": ["shinyswatch", "layout_sidebar", "layout_two_column"]
},
{
"category": "Reactivity",
"apps": [
Expand All @@ -75,6 +32,16 @@
"reactive_value"
]
},
{
"category": "Shiny Core",
"apps": [
"file_download_core",
"modules",
"orbit",
"wordle",
"static_content"
]
},
{
"category": "Interactive plots",
"apps": [
Expand Down
29 changes: 8 additions & 21 deletions examples/python/app_with_plot/app.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
import matplotlib.pyplot as plt
import numpy as np
from shiny import App, render, ui
from shiny.express import ui, input, render

app_ui = ui.page_fluid(
ui.layout_sidebar(
ui.panel_sidebar(
ui.input_slider("n", "N", 0, 100, 20),
),
ui.panel_main(
ui.output_plot("histogram"),
),
),
)
with ui.sidebar():
ui.input_slider("n", "N", 0, 100, 20)


def server(input, output, session):
@output
@render.plot(alt="A histogram")
def histogram():
np.random.seed(19680801)
x = 100 + 15 * np.random.randn(437)
plt.hist(x, input.n(), density=True)


app = App(app_ui, server, debug=True)
@render.plot(alt="A histogram")
def histogram():
np.random.seed(19680801)
x = 100 + 15 * np.random.randn(437)
plt.hist(x, input.n(), density=True)
17 changes: 5 additions & 12 deletions examples/python/basic_app/app.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
from shiny import App, render, ui
from shiny.express import ui, input, render

app_ui = ui.page_fluid(
ui.input_slider("n", "N", 0, 100, 20),
ui.output_text_verbatim("txt"),
)

ui.input_slider("n", "N", 0, 100, 20),

def server(input, output, session):
@output
@render.text
def txt():
return f"n*2 is {input.n() * 2}"


app = App(app_ui, server)
@render.text
def txt():
return f"n*2 is {input.n() * 2}"
Loading

0 comments on commit 91172d6

Please sign in to comment.