Essentially, in regards to the code below, when I select only "dog" and then move the cursor to last position "squirrel", leaving squirrel de-selected, I press Enter, the resulting menu indices will be the ones for the first and last options.
The last item under the cursor is always returned as selected (even though its un-selected in the UI) when Enter is pressed.
I'm keen to get feedback if this is intended behavior or a bug - I would have thought that only those options that have been marked for selection should be returned as selected.
Edit: Oops. I just read the docs in regards to multi_select_select_on_accept=False so this is after all intended behavior. Sorry. Feel free to close.
from simple_term_menu import TerminalMenu
def main():
def preview_function(option):
return f'{option} - is going to be a great option!'
options = ["dog", "cat", "mouse", "squirrel"]
terminal_menu = TerminalMenu(
options,
multi_select=True,
show_multi_select_hint=True,
title="Please make a choice",
preview_command=preview_function
)
menu_entry_indices = terminal_menu.show()
print(menu_entry_indices)
print(terminal_menu.chosen_menu_entries)
if __name__ == "__main__":
main()
Hopefully the title is self explanatory.
Essentially, in regards to the code below, when I select only "dog" and then move the cursor to last position "squirrel", leaving squirrel de-selected, I press Enter, the resulting menu indices will be the ones for the first and last options.
The last item under the cursor is always returned as selected (even though its un-selected in the UI) when Enter is pressed.
I'm keen to get feedback if this is intended behavior or a bug - I would have thought that only those options that have been marked for selection should be returned as selected.
Edit: Oops. I just read the docs in regards to
multi_select_select_on_accept=False
so this is after all intended behavior. Sorry. Feel free to close.