aisk / pick

create curses based interactive selection list in the terminal
MIT License
729 stars 63 forks source link

Breaking out of the menu that is displayed. #47

Closed bobolobo closed 2 years ago

bobolobo commented 4 years ago

Great utility "pick". Just wondering how to exit out of the menu that is displayed if the user decides that they do not want to pick anything because what they are looking for isn't being listed... like a list of USB drives. I have even tried a "try/except" block.


try:
    title = 'Please choose Drive to write logs to ' + str(removable_volumes) + ': '
    value, index = pick(values, title, indicator='=>')
except KeyboardInterrupt as error:  # On ctrl-c from keyboard, flush buffer, close file, exit. Break loop.
    print("\n\nExiting due to user action...")

Thanks, Bob

wong2 commented 4 years ago

It's not supported but I think you can use register_custom_handler to achieve this.

bobolobo commented 4 years ago

Ok thanks. I guess I could also add a menu pick at the end like "Exit no pick" or something like that. Thanks :)