|
1 | 1 | from shiny import reactive |
2 | | -from shiny.express import input, ui, expressify, render |
| 2 | +from shiny.express import input, ui |
3 | 3 |
|
4 | 4 | with ui.layout_sidebar(): |
5 | | - with ui.sidebar(): |
6 | | - ui.input_action_button("add", "Add 'Dynamic' tab") |
7 | | - ui.input_action_button("removeFoo", "Remove 'Foo' tabs") |
8 | | - ui.input_action_button("addFoo", "Add New 'Foo' tab") |
| 5 | + with ui.sidebar(title="Navbar page", id="sidebar"): |
| 6 | + "Home" |
| 7 | + ui.input_action_button("hideTab", "Hide 'Foo' tab") |
| 8 | + ui.input_action_button("showTab", "Show 'Foo' tab") |
| 9 | + ui.input_action_button("hideMenu", "Hide 'More' nav_menu") |
| 10 | + ui.input_action_button("showMenu", "Show 'More' nav_menu") |
9 | 11 |
|
10 | 12 | with ui.navset_tab(id="tabs"): |
11 | | - with ui.nav_panel("Hello"): |
12 | | - "This is the hello tab" |
13 | | - with ui.nav_panel("Foo", value="Foo"): |
14 | | - "This is the Foo tab" |
15 | | - with ui.nav_menu("Static", value="Menu"): |
16 | | - with ui.nav_panel("Static 1", value="s1"): |
17 | | - "Static 1" |
18 | | - with ui.nav_panel("Static 2", value="s2"): |
19 | | - "Static 2" |
| 13 | + with ui.nav_panel("Foo"): |
| 14 | + "This is the foo tab" |
| 15 | + with ui.nav_panel("Bar"): |
| 16 | + "This is the bar tab" |
| 17 | + with ui.nav_menu(title="More", value="More"): |
| 18 | + with ui.nav_panel("Table"): |
| 19 | + "Table page" |
| 20 | + with ui.nav_panel("About"): |
| 21 | + "About page" |
| 22 | + "------" |
| 23 | + "Even more!" |
| 24 | + with ui.nav_panel("Email"): |
| 25 | + "Email page" |
20 | 26 |
|
21 | | - @expressify() |
22 | | - @reactive.event(input.add) |
| 27 | + @reactive.effect() |
| 28 | + @reactive.event(input.hideTab) |
| 29 | + def _(): |
| 30 | + ui.nav_hide("tabs", target="Foo") |
| 31 | + |
| 32 | + @reactive.effect() |
| 33 | + @reactive.event(input.showTab) |
23 | 34 | def _(): |
24 | | - id = "Dynamic-" + str(input.add()) |
25 | | - ui.nav_insert( |
26 | | - "tabs", |
27 | | - ui.nav_panel(id, id), |
28 | | - target="s2", |
29 | | - position="before", |
30 | | - ) |
| 35 | + ui.nav_show("tabs", target="Foo") |
31 | 36 |
|
32 | 37 | @reactive.effect() |
33 | | - @reactive.event(input.removeFoo) |
| 38 | + @reactive.event(input.hideMenu) |
34 | 39 | def _(): |
35 | | - ui.nav_remove("tabs", target="Foo") |
| 40 | + ui.nav_hide("tabs", target="More") |
36 | 41 |
|
37 | 42 | @reactive.effect() |
38 | | - @reactive.event(input.addFoo) |
| 43 | + @reactive.event(input.showMenu) |
39 | 44 | def _(): |
40 | | - n = str(input.addFoo()) |
41 | | - ui.nav_insert( |
42 | | - "tabs", |
43 | | - ui.nav_panel("Foo-" + n, "This is the new Foo-" + n + " tab", value="Foo"), |
44 | | - target="Menu", |
45 | | - position="before", |
46 | | - select=True, |
47 | | - ) |
| 45 | + ui.nav_show("tabs", target="More") |
0 commit comments