|  | 
|  | 1 | +from shiny import App, Inputs, Outputs, Session, reactive, ui | 
|  | 2 | + | 
|  | 3 | +app_ui = ui.page_sidebar( | 
|  | 4 | +    ui.sidebar( | 
|  | 5 | +        "Home", | 
|  | 6 | +        ui.input_action_button("hideTab", "Hide 'Foo' tab"), | 
|  | 7 | +        ui.input_action_button("showTab", "Show 'Foo' tab"), | 
|  | 8 | +        ui.input_action_button("hideMenu", "Hide 'More' nav_menu"), | 
|  | 9 | +        ui.input_action_button("showMenu", "Show 'More' nav_menu"), | 
|  | 10 | +    ), | 
|  | 11 | +    ui.navset_tab( | 
|  | 12 | +        ui.nav_panel("Foo", "This is the foo tab", value="Foo"), | 
|  | 13 | +        ui.nav_panel("Bar", "This is the bar tab", value="Bar"), | 
|  | 14 | +        ui.nav_menu( | 
|  | 15 | +            "More", | 
|  | 16 | +            ui.nav_panel("Table", "Table page"), | 
|  | 17 | +            ui.nav_panel("About", "About page"), | 
|  | 18 | +            "------", | 
|  | 19 | +            "Even more!", | 
|  | 20 | +            ui.nav_panel("Email", "Email page"), | 
|  | 21 | +            value="More", | 
|  | 22 | +        ), | 
|  | 23 | +        id="tabs", | 
|  | 24 | +    ), | 
|  | 25 | +    title="Navbar page", | 
|  | 26 | +    id="sidebar", | 
|  | 27 | +) | 
|  | 28 | + | 
|  | 29 | + | 
|  | 30 | +def server(input: Inputs, output: Outputs, session: Session): | 
|  | 31 | +    @reactive.effect | 
|  | 32 | +    @reactive.event(input.hideTab) | 
|  | 33 | +    def _(): | 
|  | 34 | +        ui.update_nav_panel("tabs", target="Foo", method="hide") | 
|  | 35 | + | 
|  | 36 | +    @reactive.effect | 
|  | 37 | +    @reactive.event(input.showTab) | 
|  | 38 | +    def _(): | 
|  | 39 | +        ui.update_nav_panel("tabs", target="Foo", method="show") | 
|  | 40 | + | 
|  | 41 | +    @reactive.effect | 
|  | 42 | +    @reactive.event(input.hideMenu) | 
|  | 43 | +    def _(): | 
|  | 44 | +        ui.update_nav_panel("tabs", target="More", method="hide") | 
|  | 45 | + | 
|  | 46 | +    @reactive.effect | 
|  | 47 | +    @reactive.event(input.showMenu) | 
|  | 48 | +    def _(): | 
|  | 49 | +        ui.update_nav_panel("tabs", target="More", method="show") | 
|  | 50 | + | 
|  | 51 | + | 
|  | 52 | +app = App(app_ui, server) | 
0 commit comments