Skip to content

Commit fd89a2c

Browse files
committed
Migrate and modernize panel_well() examples
1 parent 50e8d1c commit fd89a2c

File tree

4 files changed

+85
-100
lines changed

4 files changed

+85
-100
lines changed

examples/airmass/app.py

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,37 @@
1414

1515
from shiny import App, Inputs, Outputs, Session, reactive, render, req, ui
1616

17-
app_ui = ui.page_fixed(
18-
ui.tags.h3("Air mass calculator"),
19-
ui.div(
17+
app_ui = ui.page_fillable(
18+
ui.tags.h2("Air mass calculator", {"class": "lead display-6 text-center"}),
19+
ui.layout_columns(
2020
ui.markdown(
2121
"""This Shiny app uses [Astropy](https://www.astropy.org/) to calculate the
22-
altitude (degrees above the horizon) and airmass (the amount of atmospheric
23-
air along your line of sight to an object) of one or more astronomical
24-
objects, over a given evening, at a given geographic location.
25-
"""
22+
altitude (degrees above the horizon) and airmass (the amount of atmospheric
23+
air along your line of sight to an object) of one or more astronomical
24+
objects, over a given evening, at a given geographic location.
25+
"""
2626
),
27-
class_="mb-5",
28-
),
29-
ui.row(
30-
ui.column(
31-
8,
27+
ui.card(
3228
ui.output_ui("timeinfo"),
33-
ui.output_plot("plot", height="800px"),
29+
ui.output_plot("plot", height="600px"),
3430
# For debugging
3531
# ui.output_table("table"),
36-
class_="order-2 order-sm-1",
3732
),
38-
ui.column(
39-
4,
40-
ui.panel_well(
41-
ui.input_date("date", "Date"),
42-
class_="pb-1 mb-3",
43-
),
44-
ui.panel_well(
33+
ui.TagList(
34+
ui.card(ui.input_date("date", "Date"), fill=False),
35+
ui.card(
4536
ui.input_text_area(
46-
"objects", "Target object(s)", "M1, NGC35, PLX299", rows=3
37+
"objects",
38+
"Target object(s)",
39+
"M1, NGC35, PLX299",
40+
rows=2,
4741
),
48-
class_="pb-1 mb-3",
49-
),
50-
ui.panel_well(
51-
location_ui("location"),
52-
class_="mb-3",
42+
fill=False,
5343
),
54-
class_="order-1 order-sm-2",
44+
ui.card(location_ui("location")),
5545
),
46+
col_widths=[-2, 8, -2, -1, 7, 3, -1],
47+
min_height="600px",
5648
),
5749
)
5850

examples/inputs-update/app.py

Lines changed: 60 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -4,78 +4,70 @@
44

55
app_ui = ui.page_fluid(
66
ui.panel_title("Changing the values of inputs from the server"),
7-
ui.row(
8-
ui.column(
9-
4,
10-
ui.panel_well(
11-
ui.tags.h4("These inputs control the other inputs on the page"),
12-
ui.input_text(
13-
"control_label", "This controls some of the labels:", "LABEL TEXT"
14-
),
15-
ui.input_slider(
16-
"control_num", "This controls values:", min=1, max=20, value=15
17-
),
7+
ui.layout_columns(
8+
ui.card(
9+
ui.card_header("These inputs control the other inputs on the page"),
10+
ui.input_text(
11+
"control_label", "This controls some of the labels:", "LABEL TEXT"
12+
),
13+
ui.input_slider(
14+
"control_num", "This controls values:", min=1, max=20, value=15
1815
),
1916
),
20-
ui.column(
21-
4,
22-
ui.panel_well(
23-
ui.tags.h4("These inputs are controlled by the other inputs"),
24-
ui.input_text("inText", "Text input:", value="start text"),
25-
ui.input_numeric(
26-
"inNumber", "Number input:", min=1, max=20, value=5, step=0.5
27-
),
28-
ui.input_numeric(
29-
"inNumber2", "Number input 2:", min=1, max=20, value=5, step=0.5
30-
),
31-
ui.input_slider("inSlider", "Slider input:", min=1, max=20, value=15),
32-
ui.input_slider(
33-
"inSlider2", "Slider input 2:", min=1, max=20, value=(5, 15)
34-
),
35-
ui.input_slider(
36-
"inSlider3", "Slider input 3:", min=1, max=20, value=(5, 15)
37-
),
38-
ui.input_date("inDate", "Date input:"),
39-
ui.input_date_range("inDateRange", "Date range input:"),
17+
ui.card(
18+
ui.card_header("These inputs are controlled by the other inputs"),
19+
ui.input_text("inText", "Text input:", value="start text"),
20+
ui.input_numeric(
21+
"inNumber", "Number input:", min=1, max=20, value=5, step=0.5
22+
),
23+
ui.input_numeric(
24+
"inNumber2", "Number input 2:", min=1, max=20, value=5, step=0.5
25+
),
26+
ui.input_slider("inSlider", "Slider input:", min=1, max=20, value=15),
27+
ui.input_slider(
28+
"inSlider2", "Slider input 2:", min=1, max=20, value=(5, 15)
29+
),
30+
ui.input_slider(
31+
"inSlider3", "Slider input 3:", min=1, max=20, value=(5, 15)
4032
),
33+
ui.input_date("inDate", "Date input:"),
34+
ui.input_date_range("inDateRange", "Date range input:"),
4135
),
42-
ui.column(
43-
4,
44-
ui.panel_well(
45-
ui.input_checkbox("inCheckbox", "Checkbox input", value=False),
46-
ui.input_checkbox_group(
47-
"inCheckboxGroup",
48-
"Checkbox group input:",
49-
{
50-
"option1": "label 1",
51-
"option2": "label 2",
52-
},
53-
),
54-
ui.input_radio_buttons(
55-
"inRadio",
56-
"Radio buttons:",
57-
{
58-
"option1": "label 1",
59-
"option2": "label 2",
60-
},
61-
),
62-
ui.input_select(
63-
"inSelect",
64-
"Select input:",
65-
{
66-
"option1": "label 1",
67-
"option2": "label 2",
68-
},
69-
),
70-
ui.input_select(
71-
"inSelect2",
72-
"Select input 2:",
73-
{
74-
"option1": "label 1",
75-
"option2": "label 2",
76-
},
77-
multiple=True,
78-
),
36+
ui.card(
37+
ui.card_header("These inputs are updated by the server"),
38+
ui.input_checkbox("inCheckbox", "Checkbox input", value=False),
39+
ui.input_checkbox_group(
40+
"inCheckboxGroup",
41+
"Checkbox group input:",
42+
{
43+
"option1": "label 1",
44+
"option2": "label 2",
45+
},
46+
),
47+
ui.input_radio_buttons(
48+
"inRadio",
49+
"Radio buttons:",
50+
{
51+
"option1": "label 1",
52+
"option2": "label 2",
53+
},
54+
),
55+
ui.input_select(
56+
"inSelect",
57+
"Select input:",
58+
{
59+
"option1": "label 1",
60+
"option2": "label 2",
61+
},
62+
),
63+
ui.input_select(
64+
"inSelect2",
65+
"Select input 2:",
66+
{
67+
"option1": "label 1",
68+
"option2": "label 2",
69+
},
70+
multiple=True,
7971
),
8072
ui.navset_tab(
8173
ui.nav_panel("panel1", ui.h2("This is the first panel.")),

shiny/api-examples/panel_absolute/app-core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
app_ui = ui.page_fluid(
44
ui.panel_title("A basic absolute panel example", "Demo"),
55
ui.panel_absolute(
6-
ui.panel_well(
7-
"Drag me around!", ui.input_slider("n", "N", min=0, max=100, value=20)
6+
ui.card(
7+
ui.card_header("Drag me around!"),
8+
ui.input_slider("n", "N", min=0, max=100, value=20),
89
),
910
draggable=True,
1011
width="300px",

shiny/api-examples/panel_absolute/app-express.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
ui.h2("A basic absolute panel example")
44

55
with ui.panel_absolute(draggable=True, width="300px", right="50px", top="25%"):
6-
with ui.panel_well():
7-
"Drag me around!"
6+
with ui.card():
7+
ui.card_header("Drag me around!")
88
ui.input_slider("n", "N", min=0, max=100, value=20)

0 commit comments

Comments
 (0)