How to make a scrolling menu in python-curses

前端 未结 4 597
走了就别回头了
走了就别回头了 2020-12-06 07:29

There is a way to make a scrolling menu in python-curses? I have a list of records that I got from a query in sqlite3 and I have to show them in a box but they are more than

4条回答
  •  爱一瞬间的悲伤
    2020-12-06 08:11

    I used https://github.com/wong2/pick

    >>> title = 'Please choose your favorite programming language (press SPACE to mark, ENTER to continue): '
    >>> options = ['Java', 'JavaScript', 'Python', 'PHP', 'C++', 'Erlang', 'Haskell']
    >>> pick(options, title, multi_select=True, min_selection_count=1)
    

    It creates an ncurses-based picker that takes up the entire terminal window and lets you select multiple options (it'll scroll the options if they don't all fit on the page). After you chose stuff it returns the values and their indeces:

    [('Java', 0), ('C++', 4)]
    

提交回复
热议问题