Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatically Change Pages #73

Open
alexgain opened this issue Jul 24, 2024 · 3 comments
Open

Programmatically Change Pages #73

alexgain opened this issue Jul 24, 2024 · 3 comments

Comments

@alexgain
Copy link

alexgain commented Jul 24, 2024

I have the following option menu:

    st.session_state.navigation = option_menu(
        "Trust Builder",
        navigation_options,
        icons=icons,
        menu_icon="list",
        default_index=navigation_options.index(st.session_state.navigation),
        key="selected_option"
    )

I'd like to programmatically change the option selection, e.g. via a button, in some cases. This has always run into errors.

Is there a way to do this?

@fgdvir
Copy link
Collaborator

fgdvir commented Jul 24, 2024

I'm not sure I understand exactly what you are trying to do and what is not working. Can you please elaborate?

@alexgain
Copy link
Author

I'm not sure I understand exactly what you are trying to do and what is not working. Can you please elaborate?

Normally, you have to click on the option to change the selection. This is fine, works as a nav bar should. I'd also like to change the option programmatically, e.g. via a button:

if st.button("Go to My Documents"):
   st.session_state.navigation = "My Documents"
   st.rerun()

However, this doesn't work. You can do this with other types of navigation but not option_menu.

@alexgain
Copy link
Author

bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants