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

Solve issue with manual select not working #55

Merged
merged 3 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ selected3 = option_menu(None, ["Home", "Upload", "Tasks", 'Settings'],
)

# 4. Manual Item Selection
option_list = ["Home", "Upload", "Tasks", 'Settings']
manual_select = None
if st.session_state.get('switch_button', False):
st.session_state['menu_option'] = (st.session_state.get('menu_option',0) + 1) % 4
manual_select = st.session_state['menu_option']
else:
manual_select = None
option_list_option = st.session_state['switch_button']
fgdvir marked this conversation as resolved.
Show resolved Hide resolved
manual_select = option_list.index(option_list_option)

selected4 = option_menu(None, ["Home", "Upload", "Tasks", 'Settings'],
selected4 = option_menu(None, option_list,
icons=['house', 'cloud-upload', "list-task", 'gear'],
orientation="horizontal", manual_select=manual_select, key='menu_4')
st.button(f"Move to Next {st.session_state.get('menu_option',1)}", key='switch_button')
Expand Down
2 changes: 1 addition & 1 deletion streamlit_option_menu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def option_menu(menu_title, options, default_index=0, menu_icon=None, icons=None
else:
register_callback(key, on_change, key)

if manual_select is not None and key is None:
if manual_select is not None:
default_index = manual_select

component_value = _component_func(options=options,
Expand Down