[Python] How to switch to a certain navigation panel when a button is clicked?

Discussão em 'Python' iniciado por Stack, Janeiro 19, 2025.

  1. Stack

    Stack Membro Participativo

    I have an app written in Shiny for Python with several nav panels. On the front page, which the user gets sent to first, I have one button for each other nav panel. Is there any way for me to add functionality so that clicking a button sends you to the appropriate nav panel?

    I've found ways to do this in R Shiny, but none in Shiny for Python.

    Example code:

    from shiny import App, Inputs, Outputs, Session, reactive, render, req, ui
    from shiny.express import input, ui

    with ui.nav_panel('Start'):
    ui.input_action_button("move_to_panel_1", "Move to panel 1") # clicking this moves you to panel 1
    ui.input_action_button("move_to_panel_2", "Move to panel 2") # to panel 2

    with ui.nav_panel('Panel 1'):
    with ui.card():
    @render.text
    def text1():
    return 'Text 1'

    with ui.nav_panel('Panel 2'):
    with ui.card():
    @render.text
    def text2():
    return 'Text 2'

    Continue reading...

Compartilhe esta Página