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 the max number of rows: can I make a little menu to show them all without making curses crashing?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
I used https://github.com/wong2/pick
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:
This code allows you to create a little menu in a box from a list of strings.
You can also use this code getting the list of strings from a sqlite query or from a csv file.
To edit the max number of rows of the menu you just have to edit
max_row
.If you press enter the program will print the selected string value and its position.
use this skeleton but add page-up / -down to display entries in groups of 10.
very crash-proof in python2 and python3 !
To make a scrollable widget that can scroll through text that is larger than a screenful you will need to use
curses.newpad
You can find a simple example here: https://stackoverflow.com/a/2523020/9205341
And the Python 3/Python 2 docs there.