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

Get index of selected option #46

Open
hagemon opened this issue Aug 1, 2023 · 1 comment
Open

Get index of selected option #46

hagemon opened this issue Aug 1, 2023 · 1 comment

Comments

@hagemon
Copy link

hagemon commented Aug 1, 2023

In my situation, some options may have the same option string, I can not figure which one has been chosen by users if option_menu() only returns the string of option.

For example:

option = option_menu(None, ['A', 'B', 'A', 'C'])

If users select the third option, I will get an A, but I can not figure which A has been chosen.

I hope an additional parameter return_index like:

idx, option = option_menu(None, ['A', 'B', 'A', 'C'], return_index=True)

so that I can get idx=2 after the selection of the third option.

@nicedouble
Copy link

@hagemon you can use streamlit-antd-components menu component to achieve this.

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